diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-11-29 15:26:25 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-11-29 15:26:25 +0100 |
commit | ca2fe92545dd5989a72f2e8d81aaeb778934307d (patch) | |
tree | c7f4ed248eb14aa5f3b615dfa9971e598347ef64 /src/abs8b.vhd | |
parent | dd98fe4239181753337a95d887db0d5c56e52b13 (diff) |
rename stopp to abs8b, add comments and cleanup
Diffstat (limited to 'src/abs8b.vhd')
-rw-r--r-- | src/abs8b.vhd | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/abs8b.vhd b/src/abs8b.vhd new file mode 100644 index 0000000..77b7a25 --- /dev/null +++ b/src/abs8b.vhd @@ -0,0 +1,29 @@ +library ieee; +use ieee.std_logic_1164.all; + +entity abs8b is + port( + A: in std_logic_vector(8 downto 0); + X: out std_logic_vector(8 downto 0)); +end abs8b; + +architecture Behavioral of abs8b is + component twoc + port ( + A: 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; + signal ntop: std_logic_vector(8 downto 0); +begin + -- calculate two's complement for A (A * -1) + inv: component twoc + port map( + A => A(7 downto 0), + Cin => A(8), + X => ntop(7 downto 0), + Cout => ntop(8)); + -- output -A if A < 0 else A + X <= ntop when A(8) = '1' else A; +end Behavioral; |