symlet
Member level 1
- Joined
- Oct 12, 2012
- Messages
- 41
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Activity points
- 1,616
Hai,
First of all, I want to apologize because of my mistake in the previous thread. I hope anyone can help me here. I have write vhdl code for divide by two operation. Below is the short code:
I try to add to numbers (di & a1), and then divide the sum by 2. When I simulate the testbench code in ModelSim, the values of add_temp and bm is correct. But, the values of bp is wrong (not as manual calculation). I attach the figure. Anyone please help me. Do I make anything wrong?Thank in advance
First of all, I want to apologize because of my mistake in the previous thread. I hope anyone can help me here. I have write vhdl code for divide by two operation. Below is the short code:
Code:
SRL16_a:process(CLK) begin -- SRL16
if CLK'event and CLK='1' then
if en='1' and (cycle=0 or cycle=2 or cycle=4 or cycle=6) then
sr16<=di & sr16(0 to 14); -- shift SRL16
end if;
end if;
end process;
a1<= sr16(ad1); -- output from SRL16
SM_B:process(clk,rst)
begin
if RST = '1' then
di <= (others => '0');
bp <= (others => '0');
bm <= (others => '0');
elsif CLK = '1' and CLK'event then
if en = '1' then
if d_signed =0 then
di<=unsigned(DATA_IN) - unsigned( a1_2);
else
di<= DATA_IN;
end if;
add_temp<=SXT(di,9)+a1;
bp<='0'& add_temp(8 downto 1);
bm<=SXT(di,9)-a1;
end if;
end if;
end process;