Re: [myhdl-list] newb question
Brought to you by:
jandecaluwe
|
From: Christopher L. F. <cf...@uc...> - 2008-02-26 01:26:38
|
>
> In general, I would recommend to write a wiki page with considerations
> and specs before implementing anything significant, so that others
> can review it and perhaps help with specification and implementation.
>
> Jan
I as contemplating creating a wiki page to start off a possible intbv
optimization page. At first I simply wanted to add a small (emphasis
on small) design example with profiling and the results.
While trying to do this I ran into an issue, maybe someone can point
out what I am doing wrong! I created a simple sequential multiplier
that I thought would be an ok model for exercising intbv.
Note the following isn't complete, but hopefully it will convey the
issue. The following is a very basic sequential multiplier, does a
magnitude multiplication and then does a 2's compliment at the end if
the answer should be negative. The fist time my 2's compliment code
simulates and coverts fine. But the 2's complement conversion towards
the bottom fails?? Any suggestions?
Note the commented out code doesn't work, the expression Product.next
= -1 * p0_r works but I don't believe it will convert correctly.
>>> myhdl.__version__
'0.5.1'
>>> myhdl.__revision__
'$Revision: 827 $'
>>>
<<< ------------------ >>>
@always(clk.posedge)
def sm():
if rst == 1:
state.next = 0
m0_r.next = 0
m1_r.next = 0
p0_r.next = 0
cnt.next = MU_N-1
rdy.next = 1
dv_o.next = 0
neg.next = 0
else:
if state == 0:
if dv_i == 1 and rdy == 1:
state.next = 1
if Multiplicand[MC_N-1]:
m0_r.next = ~Multiplicand + 1
else:
m0_r.next = Multiplicand
if Multiplier[MU_N-1]:
m1_r.next = ~Multiplier + 1
else:
m1_r.next = Multiplier
if Multiplicand[MC_N-1] ^ Multiplier[MU_N-1]:
neg.next = 1
else:
neg.next = 0
p0_r.next = 0
cnt.next = MU_N-1
rdy.next = 0
dv_o.next = 0
elif state == 1:
m0_r.next = m0_r << 1
m1_r.next = m1_r >> 1
if m1_r[0] == 1:
p0_r.next = p0_r + m0_r
if cnt == 0:
state.next = 2
else:
cnt.next = cnt - 1
elif state == 2:
state.next = 0
dv_o.next = 1
if neg:
Product.next = -1 * p0_r
# Should Be ----->>> Product.next = ~p0_r + 1
else:
Product.next = p0_r
rdy.next = 1
<<< ------------------ >>> |