Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8bitchecksum using one adder

Status
Not open for further replies.

nvm

Newbie level 4
Joined
Sep 13, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
50
I am trying to implement 8bit checksum using just one adder. I am trying to use for loop but having trouble naming my variables in a way that could be used in the loop. I don't have any ideas on how to go by it for now. So I am open for all suggestions. The code for now looks like this:




Code:
 library IEEE;

use IEEE.std_logic_1164.all;

entity checksum8bit is
port (
  	serialnumber : in std_logic_vector (31 downto 0);
	countervalue : in std_logic_vector(15 downto 0);
	Finalsum : out std_logic_vector (7 downto 0)
);
end checksum8bit;


architecture behavioral  of checksum8bit is
   -- signal, component etc. declarations


component checksum
	port( DataA : in    std_logic_vector(7 downto 0);
          DataB : in    std_logic_vector(7 downto 0);
          Sum   : out   std_logic_vector(7 downto 0)
        );
end component;


BEGIN

process 

VARIABLE SUM1 : STD_LOGIC_VECTOR (7 DOWNTO 0) := "00000000";
VARIABLE DATAPAC(1)  : STD_LOGIC_VECTOR (7 DOWNTO 0) := SERIALNUMBER(31 DOWNTO 24);
VARIABLE DATAPAC(2)  : STD_LOGIC_VECTOR (7 DOWNTO 0):= SERIALNUMBER(23 DOWNTO 16);
VARIABLE DATAPAC(3)  : STD_LOGIC_VECTOR (7 DOWNTO 0):= SERIALNUMBER(15 DOWNTO 8);
VARIABLE DATAPAC(4)  : STD_LOGIC_VECTOR (7 DOWNTO 0) := SERIALNUMBER (7 DOWNTO 0);
VARIABLE DATAPAC(5)   : STD_LOGIC_VECTOR (7 DOWNTO 0):= COUNTERVALUE(15 DOWNTO 8);
VARIABLE DATAPAC(6)   : STD_LOGIC_VECTOR (7 DOWNTO 0):= COUNTERVALUE (7 DOWNTO 0);
begin
for I in 1 to 6 loop
checksum_1: checksum port map (
	DataA => sum1
	DataB => DATAPAC(1),
	sum => sum1
end loop;
end process;


Finalsum <= sum1;

end behavioral ;


Thank you.
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,065
Helped
2,077
Reputation
4,171
Reaction score
2,030
Trophy points
1,393
Activity points
39,114
you cannot instantiate a component inside a process, and also you cannot map a variable to a port map. And using a for loop just elaborates to parralel hardware, so you would actually have used 6 adders.
 
  • Like
Reactions: nvm

    nvm

    Points: 2
    Helpful Answer Positive Rating

nvm

Newbie level 4
Joined
Sep 13, 2013
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
50
Okay. You have any other suggestions on how can I implement it using the least amount of gates?

you cannot instantiate a component inside a process, and also you cannot map a variable to a port map. And using a for loop just elaborates to parralel hardware, so you would actually have used 6 adders.
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,820
Helped
1,811
Reputation
3,632
Reaction score
1,772
Trophy points
1,393
Location
USA
Activity points
59,026
Okay. You have any other suggestions on how can I implement it using the least amount of gates?

If you can tolerate latency in the checksum calculation, you can share the one adder by using an FSM to control the checksum computation. The latency you will incur is directly proportional to the number of adds required to compute the checksum.

Regards
 
  • Like
Reactions: nvm

    nvm

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top