Hi,
this patches fixes a few issues with the PFPU model:
* correct computation of the sine/cosine parameters
* reset instruction counter at each new vertex
* generate an IRQ when processing is done
Now the demo renderer program is almost working in QEMU. However, besides the
lack of audio, there are still other problems related to the PFPU. For
example, it seems that the code that libFPVM generates to implement division
(based on the QUAKE instruction) returns incorrect results in QEMU (which
means that many effects: zoom, scale, ... can't work).
Sébastien
diff --git a/hw/milkymist-pfpu.c b/hw/milkymist-pfpu.c
index 34b7415..92083f9 100644
--- a/hw/milkymist-pfpu.c
+++ b/hw/milkymist-pfpu.c
@@ -244,7 +244,7 @@ static int pfpu_decode_insn(struct milkymist_pfpu *s)
case OP_SIN:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
- float t = sinf((2 * M_PI * a)/8192);
+ float t = sinf(a*(1.0f/(M_PI*4096.0f)));
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_SIN;
@@ -252,7 +252,7 @@ static int pfpu_decode_insn(struct milkymist_pfpu *s)
case OP_COS:
{
int32_t a = REINTERPRET_CAST(int32_t, s->gp_regs[reg_a]);
- float t = cosf((2 * M_PI * a)/8192);
+ float t = cosf(a*(1.0f/(M_PI*4096.0f)));
r = REINTERPRET_CAST(uint32_t, t);
latency = LATENCY_COS;
@@ -302,7 +302,7 @@ static int pfpu_decode_insn(struct milkymist_pfpu *s)
case OP_QUAKE:
{
uint32_t a = s->gp_regs[reg_a];
- r = 0x5f3759df - ((a & 0x7fffffff) >> 1);
+ r = 0x5f3759df - (a >> 1);
latency = LATENCY_QUAKE;
} break;
@@ -360,6 +360,7 @@ static void pfpu_start(struct milkymist_pfpu *s)
s->gp_regs[GPR_Y] = y;
/* run microcode on this position */
+ i = 0;
while (pfpu_decode_insn(s))
{
/* decode at most MICROCODE_WORDS instructions */
@@ -373,6 +374,8 @@ static void pfpu_start(struct milkymist_pfpu *s)
}
s->regs[R_VERTICES] = x * y;
+
+ qemu_irq_pulse(s->irq);
}
static inline int get_microcode_address(struct milkymist_pfpu *s, uint32_t addr)
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkym...@freenode
Webchat: www.milkymist.org/irc.html
Wiki: www.milkymist.org/wiki