diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-11-27 14:46:14 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-11-27 14:46:14 +0100 |
commit | d2cbbf49cf8e866af996672ff1b34bb428091261 (patch) | |
tree | 377797fd414461ef797be20fc97ee8596235e5a6 | |
parent | c8e5df8075b7539082b8afb0f161bae2fc99c8d7 (diff) |
ALU implemented but broken
l--------- | alu/alu.srcs/sources_1/binary_to_bcd_digit.vhd | 1 | ||||
-rw-r--r-- | alu/alu.xpr | 12 | ||||
-rw-r--r-- | design/alu.dig | 376 | ||||
-rw-r--r-- | src/alu.vhd | 76 | ||||
-rw-r--r-- | src/min8b.vhd | 2 | ||||
-rw-r--r-- | src/rl8b.vhd | 51 | ||||
-rw-r--r-- | src/rr8b.vhd | 39 | ||||
-rw-r--r-- | src/sl8b.vhd | 2 | ||||
-rw-r--r-- | src/sr8b.vhd | 14 |
9 files changed, 274 insertions, 299 deletions
diff --git a/alu/alu.srcs/sources_1/binary_to_bcd_digit.vhd b/alu/alu.srcs/sources_1/binary_to_bcd_digit.vhd new file mode 120000 index 0000000..516162a --- /dev/null +++ b/alu/alu.srcs/sources_1/binary_to_bcd_digit.vhd @@ -0,0 +1 @@ +../../../copyright/bijlagen/binary_to_bcd_digit.vhd
\ No newline at end of file diff --git a/alu/alu.xpr b/alu/alu.xpr index ca73037..5953561 100644 --- a/alu/alu.xpr +++ b/alu/alu.xpr @@ -59,7 +59,7 @@ <Option Name="IPStaticSourceDir" Val="$PIPUSERFILESDIR/ipstatic"/> <Option Name="EnableBDX" Val="FALSE"/> <Option Name="DSABoardId" Val="basys3"/> - <Option Name="WTXSimLaunchSim" Val="0"/> + <Option Name="WTXSimLaunchSim" Val="4"/> <Option Name="WTModelSimLaunchSim" Val="0"/> <Option Name="WTQuestaLaunchSim" Val="0"/> <Option Name="WTIesLaunchSim" Val="0"/> @@ -90,6 +90,12 @@ <FileSets Version="1" Minor="31"> <FileSet Name="sources_1" Type="DesignSrcs" RelSrcDir="$PSRCDIR/sources_1" RelGenDir="$PGENDIR/sources_1"> <Filter Type="Srcs"/> + <File Path="$PSRCDIR/sources_1/binary_to_bcd_digit.vhd"> + <FileInfo> + <Attr Name="UsedIn" Val="synthesis"/> + <Attr Name="UsedIn" Val="simulation"/> + </FileInfo> + </File> <File Path="$PSRCDIR/sources_1/binary_to_bcd.vhd"> <FileInfo> <Attr Name="UsedIn" Val="synthesis"/> @@ -196,16 +202,14 @@ <Filter Type="Srcs"/> <File Path="$PSRCDIR/sim_1/alu_tb.vhd"> <FileInfo> - <Attr Name="AutoDisabled" Val="1"/> <Attr Name="UsedIn" Val="synthesis"/> <Attr Name="UsedIn" Val="simulation"/> </FileInfo> </File> <Config> <Option Name="DesignMode" Val="RTL"/> - <Option Name="TopModule" Val="binary_to_bcd"/> + <Option Name="TopModule" Val="ALU_TB"/> <Option Name="TopLib" Val="xil_defaultlib"/> - <Option Name="TopAutoSet" Val="TRUE"/> <Option Name="TransportPathDelay" Val="0"/> <Option Name="TransportIntDelay" Val="0"/> <Option Name="SelectedSimModel" Val="rtl"/> diff --git a/design/alu.dig b/design/alu.dig index f2f354c..b7b3535 100644 --- a/design/alu.dig +++ b/design/alu.dig @@ -57,7 +57,7 @@ <int>8</int> </entry> </elementAttributes> - <pos x="760" y="540"/> + <pos x="580" y="540"/> </visualElement> <visualElement> <elementName>Out</elementName> @@ -67,7 +67,7 @@ <string>Cout</string> </entry> </elementAttributes> - <pos x="760" y="620"/> + <pos x="580" y="620"/> </visualElement> <visualElement> <elementName>Out</elementName> @@ -77,7 +77,7 @@ <string>Equal</string> </entry> </elementAttributes> - <pos x="760" y="700"/> + <pos x="580" y="700"/> </visualElement> <visualElement> <elementName>equal.dig</elementName> @@ -85,20 +85,6 @@ <pos x="380" y="1640"/> </visualElement> <visualElement> - <elementName>Decoder</elementName> - <elementAttributes> - <entry> - <string>Selector Bits</string> - <int>4</int> - </entry> - <entry> - <string>flipSelPos</string> - <boolean>true</boolean> - </entry> - </elementAttributes> - <pos x="260" y="380"/> - </visualElement> - <visualElement> <elementName>Multiplexer</elementName> <elementAttributes> <entry> @@ -114,7 +100,7 @@ <boolean>true</boolean> </entry> </elementAttributes> - <pos x="600" y="380"/> + <pos x="440" y="380"/> </visualElement> <visualElement> <elementName>add8b.dig</elementName> @@ -139,7 +125,7 @@ <int>3</int> </entry> </elementAttributes> - <pos x="700" y="620"/> + <pos x="520" y="620"/> </visualElement> <visualElement> <elementName>Const</elementName> @@ -153,137 +139,7 @@ <int>3</int> </entry> </elementAttributes> - <pos x="700" y="660"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_AplusB</string> - </entry> - </elementAttributes> - <pos x="320" y="380"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_AminB</string> - </entry> - </elementAttributes> - <pos x="320" y="400"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_BminA</string> - </entry> - </elementAttributes> - <pos x="320" y="420"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_OnlyA</string> - </entry> - </elementAttributes> - <pos x="320" y="460"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_OnlyB</string> - </entry> - </elementAttributes> - <pos x="320" y="480"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_MinA</string> - </entry> - </elementAttributes> - <pos x="320" y="500"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_MinB</string> - </entry> - </elementAttributes> - <pos x="320" y="520"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_ShiftLeftA</string> - </entry> - </elementAttributes> - <pos x="320" y="540"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_ShiftRightA</string> - </entry> - </elementAttributes> - <pos x="320" y="560"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_RotateLeftA</string> - </entry> - </elementAttributes> - <pos x="320" y="580"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_RotateRight_A</string> - </entry> - </elementAttributes> - <pos x="320" y="600"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_AllZeros</string> - </entry> - </elementAttributes> - <pos x="320" y="660"/> - </visualElement> - <visualElement> - <elementName>Tunnel</elementName> - <elementAttributes> - <entry> - <string>NetName</string> - <string>E_AllOnes</string> - </entry> - </elementAttributes> - <pos x="320" y="680"/> + <pos x="520" y="660"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -297,7 +153,7 @@ <string>R_AplusB</string> </entry> </elementAttributes> - <pos x="580" y="380"/> + <pos x="420" y="380"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -311,7 +167,7 @@ <string>R_AminB</string> </entry> </elementAttributes> - <pos x="580" y="400"/> + <pos x="420" y="400"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -325,7 +181,7 @@ <string>R_BminA</string> </entry> </elementAttributes> - <pos x="580" y="420"/> + <pos x="420" y="420"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -339,7 +195,7 @@ <string>R_OnlyA</string> </entry> </elementAttributes> - <pos x="580" y="460"/> + <pos x="420" y="460"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -353,7 +209,7 @@ <string>R_OnlyB</string> </entry> </elementAttributes> - <pos x="580" y="480"/> + <pos x="420" y="480"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -367,7 +223,7 @@ <string>R_MinA</string> </entry> </elementAttributes> - <pos x="580" y="500"/> + <pos x="420" y="500"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -381,7 +237,7 @@ <string>R_MinB</string> </entry> </elementAttributes> - <pos x="580" y="520"/> + <pos x="420" y="520"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -395,7 +251,7 @@ <string>R_ShiftLeftA</string> </entry> </elementAttributes> - <pos x="580" y="540"/> + <pos x="420" y="540"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -409,7 +265,7 @@ <string>R_ShiftRightA</string> </entry> </elementAttributes> - <pos x="580" y="560"/> + <pos x="420" y="560"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -423,7 +279,7 @@ <string>R_RotateLeftA</string> </entry> </elementAttributes> - <pos x="580" y="580"/> + <pos x="420" y="580"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -437,7 +293,7 @@ <string>R_RotateRight_A</string> </entry> </elementAttributes> - <pos x="580" y="600"/> + <pos x="420" y="600"/> </visualElement> <visualElement> <elementName>Tunnel</elementName> @@ -571,7 +427,7 @@ <int>8</int> </entry> </elementAttributes> - <pos x="440" y="660"/> + <pos x="280" y="660"/> </visualElement> <visualElement> <elementName>Const</elementName> @@ -585,7 +441,7 @@ <int>8</int> </entry> </elementAttributes> - <pos x="440" y="680"/> + <pos x="280" y="680"/> </visualElement> <visualElement> <elementName>sl8b.dig</elementName> @@ -652,16 +508,12 @@ <p2 x="380" y="1280"/> </wire> <wire> - <p1 x="460" y="640"/> - <p2 x="600" y="640"/> - </wire> - <wire> - <p1 x="300" y="580"/> - <p2 x="320" y="580"/> + <p1 x="300" y="640"/> + <p2 x="440" y="640"/> </wire> <wire> - <p1 x="580" y="580"/> - <p2 x="600" y="580"/> + <p1 x="420" y="580"/> + <p2 x="440" y="580"/> </wire> <wire> <p1 x="340" y="1540"/> @@ -672,12 +524,8 @@ <p2 x="380" y="900"/> </wire> <wire> - <p1 x="300" y="520"/> - <p2 x="320" y="520"/> - </wire> - <wire> - <p1 x="580" y="520"/> - <p2 x="600" y="520"/> + <p1 x="420" y="520"/> + <p2 x="440" y="520"/> </wire> <wire> <p1 x="320" y="1480"/> @@ -692,12 +540,8 @@ <p2 x="380" y="780"/> </wire> <wire> - <p1 x="300" y="460"/> - <p2 x="320" y="460"/> - </wire> - <wire> - <p1 x="580" y="460"/> - <p2 x="600" y="460"/> + <p1 x="420" y="460"/> + <p2 x="440" y="460"/> </wire> <wire> <p1 x="320" y="1680"/> @@ -712,44 +556,32 @@ <p2 x="460" y="1360"/> </wire> <wire> - <p1 x="300" y="400"/> - <p2 x="320" y="400"/> - </wire> - <wire> - <p1 x="580" y="400"/> - <p2 x="600" y="400"/> + <p1 x="420" y="400"/> + <p2 x="440" y="400"/> </wire> <wire> <p1 x="340" y="980"/> <p2 x="380" y="980"/> </wire> <wire> - <p1 x="700" y="660"/> - <p2 x="720" y="660"/> + <p1 x="520" y="660"/> + <p2 x="540" y="660"/> </wire> <wire> - <p1 x="300" y="660"/> - <p2 x="320" y="660"/> + <p1 x="280" y="660"/> + <p2 x="300" y="660"/> </wire> <wire> - <p1 x="440" y="660"/> - <p2 x="460" y="660"/> - </wire> - <wire> - <p1 x="460" y="660"/> - <p2 x="600" y="660"/> + <p1 x="300" y="660"/> + <p2 x="440" y="660"/> </wire> <wire> <p1 x="340" y="1240"/> <p2 x="380" y="1240"/> </wire> <wire> - <p1 x="300" y="600"/> - <p2 x="320" y="600"/> - </wire> - <wire> - <p1 x="580" y="600"/> - <p2 x="600" y="600"/> + <p1 x="420" y="600"/> + <p2 x="440" y="600"/> </wire> <wire> <p1 x="440" y="1560"/> @@ -772,20 +604,16 @@ <p2 x="380" y="1180"/> </wire> <wire> - <p1 x="640" y="540"/> - <p2 x="680" y="540"/> + <p1 x="480" y="540"/> + <p2 x="500" y="540"/> </wire> <wire> - <p1 x="300" y="540"/> - <p2 x="320" y="540"/> + <p1 x="420" y="540"/> + <p2 x="440" y="540"/> </wire> <wire> - <p1 x="580" y="540"/> - <p2 x="600" y="540"/> - </wire> - <wire> - <p1 x="680" y="540"/> - <p2 x="760" y="540"/> + <p1 x="500" y="540"/> + <p2 x="580" y="540"/> </wire> <wire> <p1 x="440" y="1120"/> @@ -796,12 +624,8 @@ <p2 x="380" y="1120"/> </wire> <wire> - <p1 x="300" y="480"/> - <p2 x="320" y="480"/> - </wire> - <wire> - <p1 x="580" y="480"/> - <p2 x="600" y="480"/> + <p1 x="420" y="480"/> + <p2 x="440" y="480"/> </wire> <wire> <p1 x="340" y="1440"/> @@ -816,12 +640,8 @@ <p2 x="340" y="740"/> </wire> <wire> - <p1 x="300" y="420"/> - <p2 x="320" y="420"/> - </wire> - <wire> - <p1 x="580" y="420"/> - <p2 x="600" y="420"/> + <p1 x="420" y="420"/> + <p2 x="440" y="420"/> </wire> <wire> <p1 x="320" y="1380"/> @@ -832,36 +652,28 @@ <p2 x="380" y="1640"/> </wire> <wire> - <p1 x="240" y="360"/> - <p2 x="280" y="360"/> - </wire> - <wire> - <p1 x="280" y="360"/> - <p2 x="620" y="360"/> - </wire> - <wire> - <p1 x="300" y="680"/> - <p2 x="320" y="680"/> - </wire> - <wire> - <p1 x="440" y="680"/> - <p2 x="600" y="680"/> + <p1 x="280" y="680"/> + <p2 x="440" y="680"/> </wire> <wire> <p1 x="360" y="1000"/> <p2 x="380" y="1000"/> </wire> <wire> - <p1 x="740" y="620"/> - <p2 x="760" y="620"/> + <p1 x="240" y="360"/> + <p2 x="460" y="360"/> + </wire> + <wire> + <p1 x="560" y="620"/> + <p2 x="580" y="620"/> </wire> <wire> - <p1 x="680" y="620"/> - <p2 x="700" y="620"/> + <p1 x="500" y="620"/> + <p2 x="520" y="620"/> </wire> <wire> - <p1 x="460" y="620"/> - <p2 x="600" y="620"/> + <p1 x="300" y="620"/> + <p2 x="440" y="620"/> </wire> <wire> <p1 x="440" y="1260"/> @@ -872,24 +684,16 @@ <p2 x="380" y="1580"/> </wire> <wire> - <p1 x="300" y="560"/> - <p2 x="320" y="560"/> - </wire> - <wire> - <p1 x="580" y="560"/> - <p2 x="600" y="560"/> + <p1 x="420" y="560"/> + <p2 x="440" y="560"/> </wire> <wire> <p1 x="320" y="880"/> <p2 x="380" y="880"/> </wire> <wire> - <p1 x="300" y="500"/> - <p2 x="320" y="500"/> - </wire> - <wire> - <p1 x="580" y="500"/> - <p2 x="600" y="500"/> + <p1 x="420" y="500"/> + <p2 x="440" y="500"/> </wire> <wire> <p1 x="440" y="1460"/> @@ -908,36 +712,24 @@ <p2 x="460" y="1080"/> </wire> <wire> - <p1 x="460" y="440"/> - <p2 x="600" y="440"/> + <p1 x="300" y="440"/> + <p2 x="440" y="440"/> </wire> <wire> - <p1 x="300" y="380"/> - <p2 x="320" y="380"/> - </wire> - <wire> - <p1 x="580" y="380"/> - <p2 x="600" y="380"/> + <p1 x="420" y="380"/> + <p2 x="440" y="380"/> </wire> <wire> <p1 x="340" y="1340"/> <p2 x="380" y="1340"/> </wire> <wire> - <p1 x="720" y="700"/> - <p2 x="760" y="700"/> + <p1 x="540" y="700"/> + <p2 x="580" y="700"/> </wire> <wire> <p1 x="440" y="1660"/> - <p2 x="720" y="1660"/> - </wire> - <wire> - <p1 x="720" y="640"/> - <p2 x="720" y="660"/> - </wire> - <wire> - <p1 x="720" y="700"/> - <p2 x="720" y="1660"/> + <p2 x="540" y="1660"/> </wire> <wire> <p1 x="320" y="780"/> @@ -1016,28 +808,32 @@ <p2 x="340" y="1540"/> </wire> <wire> - <p1 x="280" y="360"/> - <p2 x="280" y="380"/> + <p1 x="500" y="540"/> + <p2 x="500" y="620"/> + </wire> + <wire> + <p1 x="540" y="700"/> + <p2 x="540" y="1660"/> </wire> <wire> - <p1 x="680" y="540"/> - <p2 x="680" y="620"/> + <p1 x="540" y="640"/> + <p2 x="540" y="660"/> </wire> <wire> - <p1 x="620" y="360"/> - <p2 x="620" y="380"/> + <p1 x="300" y="440"/> + <p2 x="300" y="620"/> </wire> <wire> - <p1 x="460" y="440"/> - <p2 x="460" y="620"/> + <p1 x="300" y="620"/> + <p2 x="300" y="640"/> </wire> <wire> - <p1 x="460" y="620"/> - <p2 x="460" y="640"/> + <p1 x="300" y="640"/> + <p2 x="300" y="660"/> </wire> <wire> - <p1 x="460" y="640"/> - <p2 x="460" y="660"/> + <p1 x="460" y="360"/> + <p2 x="460" y="380"/> </wire> </wires> <measurementOrdering/> diff --git a/src/alu.vhd b/src/alu.vhd index bac273b..0022b4e 100644 --- a/src/alu.vhd +++ b/src/alu.vhd @@ -24,7 +24,8 @@ architecture Behavioral of ALU is R_RotateLeftA, R_RotateRightA, R_AllZeros, - R_AllOnes: std_logic_vector(7 downto 0); + R_AllOnes, + R: std_logic_vector(7 downto 0); component add8b is port ( A: in std_logic_vector(7 downto 0); @@ -46,6 +47,26 @@ architecture Behavioral of ALU is A: in std_logic_vector(7 downto 0); X: out std_logic_vector(7 downto 0)); end component; + component sl8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; + component sr8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; + component rl8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; + component rr8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; component eq8b is port ( A: in std_logic_vector(7 downto 0); @@ -57,8 +78,56 @@ begin R_AllOnes <= x"ff"; R_AllZeros <= x"00"; + AplusB: component add8b + port map( + A => A, + B => B, + Cin => '0', + X => R_AplusB, + Cout => open); + AminB: component min8b + port map( + A => A, + B => B, + Cin => '0', + X => R_AminB, + Cout => open); + BminA: component min8b + port map( + A => B, + B => A, + Cin => '0', + X => R_BminA, + Cout => open); + R_OnlyA <= A; + R_OnlyB <= B; + MinA: component twoc + port map(A => A, X => R_MinA); + MinB: component twoc + port map(A => B, X => R_MinA); + ShiftLeftA: component sl8b + port map( + A => A, + S => B, + X => R_ShiftLeftA); + ShiftRightA: component sr8b + port map( + A => A, + S => B, + X => R_ShiftRightA); + RotateLeftA: component rl8b + port map( + A => A, + S => B, + X => R_RotateLeftA); + RotateRightA: component rr8b + port map( + A => A, + S => B, + X => R_RotateRightA); + with Op select - Res <= + R <= R_AplusB when x"0", R_AminB when x"1", R_BminA when x"2", @@ -81,5 +150,6 @@ begin A => A, B => B, Equal => Equal); - Cout <= Res(7); + Res <= R; + Cout <= R(7); end Behavioral; diff --git a/src/min8b.vhd b/src/min8b.vhd index 449169f..f2623aa 100644 --- a/src/min8b.vhd +++ b/src/min8b.vhd @@ -27,7 +27,7 @@ architecture Behavioral of min8b is Cout: out std_logic); end component; begin - twoc: component twoc + complement: component twoc port map ( A => B, X => Bmin); diff --git a/src/rl8b.vhd b/src/rl8b.vhd index e69de29..b7f0e5a 100644 --- a/src/rl8b.vhd +++ b/src/rl8b.vhd @@ -0,0 +1,51 @@ +LIBRARY ieee; +USE ieee.std_logic_1164.all; +USE ieee.numeric_std.all; + +entity rl8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); +end rl8b; + +architecture Behavioral of rl8b is + signal sr_val: std_logic_vector(7 downto 0); -- shift right value + signal part_l, part_r: std_logic_vector(7 downto 0); -- left and right part of cylinder + component sl8b + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; + component sr8b + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; + component min8b + port ( + A: in std_logic_vector(7 downto 0); + B: in std_logic_vector(7 downto 0); + Cin: in std_logic; + X: out std_logic_vector(7 downto 0); + Cout: out std_logic); + end component; +begin + calc_sr_val: component min8b + port map( + A => x"08", + B => S, + Cin => '0', + X => sr_val, + Cout => open); + left: component sl8b + port map( + A => A, + S => S, + X => part_l); + right: component sr8b + port map( + A => A, + S => sr_val, + X => part_r); + X <= part_l or part_r; +end Behavioral; diff --git a/src/rr8b.vhd b/src/rr8b.vhd index e69de29..e96f9c0 100644 --- a/src/rr8b.vhd +++ b/src/rr8b.vhd @@ -0,0 +1,39 @@ +LIBRARY ieee; +USE ieee.std_logic_1164.all; +USE ieee.numeric_std.all; + +entity rr8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); +end rr8b; + +architecture Behavioral of rr8b is + signal s_val: std_logic_vector(7 downto 0); -- shift value + component rl8b + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); + end component; + component min8b + port ( + A: in std_logic_vector(7 downto 0); + B: in std_logic_vector(7 downto 0); + Cin: in std_logic; + X: out std_logic_vector(7 downto 0); + Cout: out std_logic); + end component; +begin + calc_val: component min8b + port map( + A => x"08", + B => S, + Cin => '0', + X => s_val, + Cout => open); + rotate: component rl8b + port map( + A => A, + S => s_val, + X => X); +end Behavioral; diff --git a/src/sl8b.vhd b/src/sl8b.vhd index befa2a5..67b71dd 100644 --- a/src/sl8b.vhd +++ b/src/sl8b.vhd @@ -10,5 +10,5 @@ end sl8b; architecture Behavioral of sl8b is begin - X <= std_logic_vector(shift_left(unsigned(A), 1)); + X <= std_logic_vector(shift_left(unsigned(A), natural(to_integer(unsigned(S))))); end Behavioral; diff --git a/src/sr8b.vhd b/src/sr8b.vhd index e69de29..b81b9d8 100644 --- a/src/sr8b.vhd +++ b/src/sr8b.vhd @@ -0,0 +1,14 @@ +LIBRARY ieee; +USE ieee.std_logic_1164.all; +USE ieee.numeric_std.all; + +entity sr8b is + port ( + A, S: in std_logic_vector(7 downto 0); + X: out std_logic_vector(7 downto 0)); +end sr8b; + +architecture Behavioral of sr8b is +begin + X <= std_logic_vector(shift_right(unsigned(A), natural(to_integer(unsigned(S))))); +end Behavioral; |