OpenCores
URL https://opencores.org/ocsvn/generic_booth_multipler/generic_booth_multipler/trunk

Subversion Repositories generic_booth_multipler

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

/generic_booth_multipler/trunk/rtl/modules/00.Adder.vhd
0,0 → 1,32
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity Adder is
port(
A : in std_logic_vector;
B : in std_logic_vector;
Cin : in std_logic;
S : out std_logic_vector;
Cout : out std_logic);
end Adder;
 
architecture Behavioral of Adder is
component FullAdder is
port(
A :in std_logic;
B :in std_logic;
Cin :in std_logic;
Sum :out std_logic;
Cout:out std_logic);
end component;
signal carry : std_logic_vector(A'length downto 0);
begin
carry(0) <= cin;
cout <= carry(A'length);
AdderGen : for i in A'range generate
FA : FullAdder port map(A(i),B(i),carry(i),S(i),carry(i+1));
end generate;
 
 
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.Alu.vhd
0,0 → 1,36
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity Alu is
port(
A : in std_logic_vector;
B : in std_logic_vector;
op : in std_logic;
S : out std_logic_vector);
end Alu;
 
architecture Behavioral of Alu is
component Adder is
port(
A : in std_logic_vector;
B : in std_logic_vector;
Cin : in std_logic;
S : out std_logic_vector;
Cout : out std_logic);
end component;
component XorCrearor is
port(
input1 : in std_logic;
input2 : in std_logic_vector;
result : out std_logic_vector);
end component;
signal xored: std_logic_vector(A'range);
begin
XO :XorCrearor port map(op,B,xored);
ADD:ADDER port map(A,xored,op,S,open);
 
 
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.Ander.vhd
0,0 → 1,23
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity Ander is
port(
input1 : in std_logic;
input2 : in std_logic_vector;
result : out std_logic_vector);
end Ander;
 
architecture Behavioral of Ander is
 
begin
process(input1,input2)
begin
for i in input2'range loop
result(i) <= input1 and input2(i);
end loop;
end process;
 
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.BoothEncoder.vhd
0,0 → 1,20
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity BoothEncoder is
port(
input1 : in std_logic;
input0 : in std_logic;
operator : out std_logic;
product : out std_logic
);
end BoothEncoder;
 
architecture Behavioral of BoothEncoder is
 
begin
product <= input1 xor input0 ;
operator <= input1;
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.COUNTER.vhd
0,0 → 1,32
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
 
entity counter is
port(
clock : in std_logic;
reset : in std_logic;
value : out std_logic_vector);
end counter;
 
architecture behavioral of counter is
 
signal internal_value : std_logic_vector(value'range):= (others => '0');
 
begin
 
counter_proc:
process(clock)
begin
if (rising_edge(clock)) then
if (reset = '1') then
internal_value <= (others => '0');
else
internal_value <= internal_value + '1';
end if;
end if;
end process;
value <= internal_value;
end;
/generic_booth_multipler/trunk/rtl/modules/00.FullAdder.vhd
0,0 → 1,19
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity FullAdder is
port(
A :in std_logic;
B :in std_logic;
Cin :in std_logic;
Sum :out std_logic;
Cout:out std_logic);
end FullAdder;
 
architecture Behavioral of FullAdder is
 
begin
Cout <= (A AND B)OR(B AND Cin)OR(Cin AND A);
Sum <= A XOR B XOR Cin;
end Behavioral;
/generic_booth_multipler/trunk/rtl/modules/00.LeftShiftReg.vhd
0,0 → 1,32
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity LeftShiftReg is
port(
clock :in std_logic;
enable :in std_logic;
shift :in std_logic;
din :in std_logic_vector;
dout :out std_logic_vector);
end LeftShiftReg;
architecture Behavioral of LeftShiftReg is
signal data : std_logic_vector(din'range);
begin
process(clock,enable,shift)
begin
if(clock'event and clock = '1')then
if(enable = '1')then
data <= din;
elsif(shift = '1') then
data <= data(din'length-2 downto 0) & '0';
else
data <= data;
end if;
end if;
end process;
dout <= data;
 
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.Regeister.vhd
0,0 → 1,32
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity Regeister is
port(
clock :in std_logic;
enable :in std_logic;
reset :in std_logic;
din :in std_logic_vector;
dout :out std_logic_vector);
end Regeister;
 
architecture Behavioral of Regeister is
signal data :std_logic_vector(din'range):=(OTHERS=>'0');
begin
process(clock)
begin
if(clock'event and clock='1')then
if(reset ='1' )then
data <=(others =>'0');
elsif(enable = '1')then
data <= din;
else
data <= data;
end if;
end if;
end process;
dout <= data;
 
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.RightShiftReg.vhd
0,0 → 1,30
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity RightShiftReg is
port(
clock :in std_logic;
enable :in std_logic;
shift :in std_logic;
din :in std_logic_vector;
dout :out std_logic_vector(1 downto 0));
end RightShiftReg;
 
architecture Behavioral of RightShiftReg is
signal data : std_logic_vector(din'length-1 downto 0);
begin
process(clock,enable,shift)
begin
if(clock'event and clock = '1')then
if(enable = '1')then
data <= din;
elsif(shift = '1') then
data <= '0' & data(din'length-1 downto 1);
else
data <= data;
end if;
end if;
end process;
dout <= data(1 downto 0);
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/00.XorCrearor.vhd
0,0 → 1,24
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity XorCrearor is
port(
input1 : in std_logic;
input2 : in std_logic_vector;
result : out std_logic_vector);
end XorCrearor;
 
architecture Behavioral of XorCrearor is
 
begin
process(input1,input2)
begin
for i in input2'range loop
result(i) <= input1 xor input2(i);
end loop;
end process;
 
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/01.BoothController.vhd
0,0 → 1,76
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
 
entity BoothController is
Port (
clock : in std_logic;
reset : in std_logic;
start : in std_logic;
interrupt : in std_logic;
load : out std_logic;
shift : out std_logic;
cnt_clear : out std_logic;
reg_clear : out std_logic;
ready : out std_logic);
end BoothController;
architecture Behavioral of BoothController is
 
type state_t is (reset_st,reset_and_load_st,calculating_st, calculated_st, done_st);
signal current_state : state_t := reset_st;
signal next_state : state_t := reset_st;
begin
process(clock, reset)
begin
if(reset = '1') then
current_state <= reset_st;
elsif (rising_edge(clock)) then
current_state <= next_state;
end if;
end process;
process(current_state, start, interrupt)
begin
load <= '0';
shift <= '0';
cnt_clear <= '0';
reg_clear <= '0';
case current_state is
 
when reset_st =>
if(start = '1') then
load <= '1';
reg_clear <= '1';
next_state <= reset_and_load_st;
else
next_state <= reset_st;
end if;
when reset_and_load_st =>
shift <= '1';
cnt_clear <= '1';
next_state <= calculating_st;
when calculating_st =>
if(interrupt = '1') then
next_state <= calculated_st;
else
shift <= '1';
next_state <= calculating_st;
end if;
when calculated_st =>
next_state <= done_st;
when done_st =>
next_state <= done_st;
end case;
end process;
ready <= '1' when current_state = done_st else '0';
end Behavioral;
/generic_booth_multipler/trunk/rtl/modules/01.BoothDatapath.vhd
0,0 → 1,119
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity BoothDatapath is
port(
clock :in std_logic;
reset :in std_logic;
load :in std_logic;
shift :in std_logic;
X : in std_logic_vector;
Y : in std_logic_vector;
P : out std_logic_vector);
end BoothDatapath;
 
architecture Behavioral of BoothDatapath is
 
component Regeister is
port(
clock :in std_logic;
enable :in std_logic;
reset :in std_logic;
din :in std_logic_vector;
dout :out std_logic_vector);
end component;
 
component LeftShiftReg is
port(
clock :in std_logic;
enable :in std_logic;
shift :in std_logic;
din :in std_logic_vector;
dout :out std_logic_vector);
end component;
component RightShiftReg is
port(
clock : in std_logic;
enable : in std_logic;
shift : in std_logic;
din : in std_logic_vector;
dout : out std_logic_vector(1 downto 0));
end component;
component BoothEncoder is
port(
input1 : in std_logic;
input0 : in std_logic;
operator : out std_logic;
product : out std_logic
);
end component;
 
component Alu is
port(
A : in std_logic_vector;
B : in std_logic_vector;
op : in std_logic;
S : out std_logic_vector);
end component;
component Ander is
port(
input1 : in std_logic;
input2 : in std_logic_vector;
result : out std_logic_vector);
end component;
signal sign_extended_x,andout,alu_out,p_out,X_reg_dout: std_logic_vector(2*X'length -1 downto 0);
signal lessTwoBits : std_logic_vector(1 downto 0);
signal operator,product : std_logic;
signal Y_concat_zero : std_logic_vector(y'length downto 0);
begin
Y_concat_zero <= Y & '0';
sign_extended_x(X'range) <= X;
sign_extended_x(sign_extended_x'length - 1 downto X'length) <= (others=> X(X'length-1));
Booth_ENC: BoothEncoder
port map(input1 => lessTwoBits(1),
input0=>lessTwoBits(0),
operator => operator,
product => product);
Y_REG : RightShiftReg
port map(
clock => clock,
enable => load,
shift =>shift,
din => Y_concat_zero,
dout => lessTwoBits);
X_REG : LeftShiftReg
port map(
clock => clock,
enable => load,
shift => shift,
din => sign_extended_x,
dout => X_reg_dout);
ANDing : Ander
port map(
input1 => product,
input2 => X_reg_dout,
result => AndOut);
Add_Sub : ALU
port map(
A => P_out,
B => AndOut,
op => operator,
S => ALU_Out);
P_REG : Regeister
port map(
clock => clock,
enable => shift,
reset => reset,
din => ALU_Out,
dout => P_out);
P <= P_out;
end Behavioral;
 
/generic_booth_multipler/trunk/rtl/modules/02.BoothMultiplier.vhd
0,0 → 1,91
 
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
entity BoothMultiplier is
generic(COUNTER_SIZE : positive := 2);
port(
clock : in std_logic;
clear : in std_logic;
start : in std_logic;
X_data: in std_logic_vector(2**COUNTER_SIZE-1 downto 0);
Y_data: in std_logic_vector(2**COUNTER_SIZE-1 downto 0);
ready : out std_logic;
Result: out std_logic_vector(2*(2**COUNTER_SIZE)-1 downto 0));
end BoothMultiplier;
 
architecture Behavioral of BoothMultiplier is
 
component counter is
port( clock : in std_logic;
reset : in std_logic;
value : out std_logic_vector);
end component counter;
component BoothDatapath is
port(
clock :in std_logic;
reset :in std_logic;
load :in std_logic;
shift :in std_logic;
X :in std_logic_vector;
Y :in std_logic_vector;
P :out std_logic_vector);
end component BoothDatapath;
component BoothController is
Port (
clock : in std_logic;
reset : in std_logic;
start : in std_logic;
interrupt : in std_logic;
load : out std_logic;
shift : out std_logic;
cnt_clear : out std_logic;
reg_clear : out std_logic;
ready : out std_logic);
end component BoothController;
signal load : std_logic;
signal counter_value : std_logic_vector(COUNTER_SIZE - 1 downto 0);
signal shift : std_logic;
signal counter_interrupt : std_logic;
signal cnt_clear : std_logic;
signal reg_clear : std_logic;
CONSTANT ONES : std_logic_vector(COUNTER_SIZE - 1 downto 0) := (others => '1');
begin
datapath: BoothDatapath
port map(
clock => clock,
reset => reg_clear,
load => load,
shift => shift,
X => X_data,
Y => Y_data,
P => Result);
counter_unit: counter
port map(
clock => clock,
reset => cnt_clear,
value => counter_value);
counter_interrupt <= '1' when (counter_value = ONES) else '0';
controller: BoothController
port map(
clock => clock,
reset => clear,
start => start,
interrupt => counter_interrupt,
load => load,
shift => shift,
cnt_clear => cnt_clear,
reg_clear => reg_clear,
ready => ready);
end Behavioral;
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.