URL
https://opencores.org/ocsvn/nanoblaze/nanoblaze/trunk
Subversion Repositories nanoblaze
Compare Revisions
- This comparison shows the changes necessary to convert path
/nanoblaze
- from Rev 7 to Rev 8
- ↔ Reverse comparison
Rev 7 → Rev 8
/trunk/Circuit/programRom.vhd
0,0 → 1,476
--############################################################################## |
-- |
-- programRom |
-- NanoBlaze instruction ROM |
-- |
-- The architecture is created by the assembler. |
-- The systhesiser maps it into a Block RAM. |
-- |
-------------------------------------------------------------------------------- |
-- |
-- Versions / Authors |
-- 1.0 Francois Corthay first implementation |
-- |
-- Provided under GNU LGPL licence: <http://www.gnu.org/copyleft/lesser.html> |
-- |
-- by the electronics group of "HES-SO//Valais Wallis", in Switzerland: |
-- <http://www.hevs.ch/en/rad-instituts/institut-systemes-industriels/>. |
-- |
-------------------------------------------------------------------------------- |
-- |
-- Hierarchy |
-- Used by "nanoblaze". |
-- |
--############################################################################## |
|
LIBRARY ieee; |
USE ieee.std_logic_1164.all; |
USE ieee.numeric_std.all; |
|
ENTITY programRom IS |
GENERIC( |
addressBitNb : positive := 8; |
dataBitNb : positive := 8 |
); |
PORT( |
reset : IN std_uLogic; |
clock : IN std_uLogic; |
en : IN std_uLogic; |
address : IN unsigned(addressBitNb-1 DOWNTO 0); |
dataOut : OUT std_ulogic_vector(dataBitNb-1 DOWNTO 0) |
); |
END programRom ; |
|
--============================================================================== |
|
ARCHITECTURE mapped OF programRom IS |
|
subtype opCodeType is std_ulogic_vector(5 downto 0); |
constant opLoadC : opCodeType := "000000"; |
constant opLoadR : opCodeType := "000001"; |
constant opInputC : opCodeType := "000100"; |
constant opInputR : opCodeType := "000101"; |
constant opFetchC : opCodeType := "000110"; |
constant opFetchR : opCodeType := "000111"; |
constant opAndC : opCodeType := "001010"; |
constant opAndR : opCodeType := "001011"; |
constant opOrC : opCodeType := "001100"; |
constant opOrR : opCodeType := "001101"; |
constant opXorC : opCodeType := "001110"; |
constant opXorR : opCodeType := "001111"; |
constant opTestC : opCodeType := "010010"; |
constant opTestR : opCodeType := "010011"; |
constant opCompC : opCodeType := "010100"; |
constant opCompR : opCodeType := "010101"; |
constant opAddC : opCodeType := "011000"; |
constant opAddR : opCodeType := "011001"; |
constant opAddCyC : opCodeType := "011010"; |
constant opAddCyR : opCodeType := "011011"; |
constant opSubC : opCodeType := "011100"; |
constant opSubR : opCodeType := "011101"; |
constant opSubCyC : opCodeType := "011110"; |
constant opSubCyR : opCodeType := "011111"; |
constant opShRot : opCodeType := "100000"; |
constant opOutputC : opCodeType := "101100"; |
constant opOutputR : opCodeType := "101101"; |
constant opStoreC : opCodeType := "101110"; |
constant opStoreR : opCodeType := "101111"; |
|
subtype shRotCinType is std_ulogic_vector(2 downto 0); |
constant shRotLdC : shRotCinType := "00-"; |
constant shRotLdM : shRotCinType := "01-"; |
constant shRotLdL : shRotCinType := "10-"; |
constant shRotLd0 : shRotCinType := "110"; |
constant shRotLd1 : shRotCinType := "111"; |
|
constant registerAddressBitNb : positive := 4; |
constant shRotPadLength : positive |
:= dataOut'length - opCodeType'length - registerAddressBitNb |
- 1 - shRotCinType'length; |
subtype shRotDirType is std_ulogic_vector(1+shRotPadLength-1 downto 0); |
constant shRotL : shRotDirType := (0 => '0', others => '-'); |
constant shRotR : shRotDirType := (0 => '1', others => '-'); |
|
subtype branchCodeType is std_ulogic_vector(4 downto 0); |
constant brRet : branchCodeType := "10101"; |
constant brCall : branchCodeType := "11000"; |
constant brJump : branchCodeType := "11010"; |
constant brReti : branchCodeType := "11100"; |
constant brEni : branchCodeType := "11110"; |
|
subtype branchConditionType is std_ulogic_vector(2 downto 0); |
constant brDo : branchConditionType := "000"; |
constant brZ : branchConditionType := "100"; |
constant brNZ : branchConditionType := "101"; |
constant brC : branchConditionType := "110"; |
constant brNC : branchConditionType := "111"; |
|
subtype memoryWordType is std_ulogic_vector(dataOut'range); |
type memoryArrayType is array (0 to 2**address'length-1) of memoryWordType; |
|
signal memoryArray : memoryArrayType := ( |
--=============================================================== |
-- 1) Test logical operations with direct values |
----------------------------------------------------------------- |
16#000# => opLoadC & "0111" & "00000001", -- LOAD s7, 01 |
----------------------------------------------------------------- |
-- Test "LOAD", "AND" |
----------------------------------------------------------------- |
16#001# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#002# => opAndC & "0000" & "00110011", -- AND s0, 33 |
16#003# => opCompC & "0000" & "00000011", -- COMPARE s0, 03 |
16#004# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "OR" |
----------------------------------------------------------------- |
16#005# => opLoadC & "0001" & "00001111", -- LOAD s1, 0F |
16#006# => opOrC & "0001" & "00110011", -- OR s1, 33 |
16#007# => opCompC & "0001" & "00111111", -- COMPARE s1, 3F |
16#008# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "XOR" |
----------------------------------------------------------------- |
16#009# => opLoadC & "0010" & "00001111", -- LOAD s2, 0F |
16#00A# => opXorC & "0010" & "00110011", -- XOR s2, 33 |
16#00B# => opCompC & "0010" & "00111100", -- COMPARE s2, 3C |
16#00C# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 2) Test logical operations with registers |
----------------------------------------------------------------- |
16#00D# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "LOAD" |
----------------------------------------------------------------- |
16#00E# => opLoadC & "0000" & "00110011", -- LOAD s0, 33 |
16#00F# => opLoadR & "0011" & "0000----", -- LOAD s3, s0 |
16#010# => opCompC & "0011" & "00110011", -- COMPARE s3, 33 |
16#011# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "AND" |
----------------------------------------------------------------- |
16#012# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#013# => opAndR & "0000" & "0011----", -- AND s0, s3 |
16#014# => opCompC & "0000" & "00000011", -- COMPARE s0, 03 |
16#015# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "OR" |
----------------------------------------------------------------- |
16#016# => opLoadC & "0001" & "00001111", -- LOAD s1, 0F |
16#017# => opOrR & "0001" & "0011----", -- OR s1, s3 |
16#018# => opCompC & "0001" & "00111111", -- COMPARE s1, 3F |
16#019# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "XOR" |
----------------------------------------------------------------- |
16#01A# => opLoadC & "0010" & "00001111", -- LOAD s2, 0F |
16#01B# => opXorR & "0010" & "0011----", -- XOR s2, s3 |
16#01C# => opCompC & "0010" & "00111100", -- COMPARE s2, 3C |
16#01D# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 3) Test arithmetic operations with constants |
----------------------------------------------------------------- |
16#01E# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "ADD" and "ADDCY" |
----------------------------------------------------------------- |
16#01F# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#020# => opAddC & "0000" & "00110001", -- ADD s0, 31 ; 40 |
16#021# => opAddCyC & "0000" & "11110000", -- ADDCY s0, F0 ; 130 |
16#022# => opAddCyC & "0000" & "11110000", -- ADDCY s0, F0 ; 121 |
16#023# => opAddC & "0000" & "00001111", -- ADD s0, 0F ; 30 |
16#024# => opCompC & "0000" & "00110000", -- COMPARE s0, 30 |
16#025# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "SUB" and "SUBCY" |
----------------------------------------------------------------- |
16#026# => opLoadC & "0001" & "00001111", -- LOAD s1, 0F |
16#027# => opSubC & "0001" & "00001100", -- SUB s1, 0C ; 03 |
16#028# => opSubCyC & "0001" & "11110000", -- SUBCY s1, F0 ; 113 |
16#029# => opSubCyC & "0001" & "11110000", -- SUBCY s1, F0 ; 22 |
16#02A# => opSubC & "0001" & "00000001", -- SUB s1, 01 ; 21 |
16#02B# => opCompC & "0001" & "00100001", -- COMPARE s1, 21 |
16#02C# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 4) Test arithmetic operations with registers |
----------------------------------------------------------------- |
16#02D# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "ADD" and "ADDCY" |
----------------------------------------------------------------- |
16#02E# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#02F# => opLoadC & "0001" & "00110001", -- LOAD s1, 31 |
16#030# => opLoadC & "0010" & "11110000", -- LOAD s2, F0 |
16#031# => opLoadC & "0011" & "00001111", -- LOAD s3, 0F |
16#032# => opAddR & "0000" & "0001----", -- ADD s0, s1 ; 40 |
16#033# => opAddCyR & "0000" & "0010----", -- ADDCY s0, s2 ; 130 |
16#034# => opAddCyR & "0000" & "0010----", -- ADDCY s0, s2 ; 121 |
16#035# => opAddR & "0000" & "0011----", -- ADD s0, s3 ; 30 |
16#036# => opCompC & "0000" & "00110000", -- COMPARE s0, 30 |
16#037# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "SUB" and "SUBCY" |
----------------------------------------------------------------- |
16#038# => opLoadC & "0001" & "00001111", -- LOAD s1, 0F |
16#039# => opLoadC & "0000" & "00001100", -- LOAD s0, 0C |
16#03A# => opLoadC & "0010" & "11110000", -- LOAD s2, F0 |
16#03B# => opLoadC & "0011" & "00000001", -- LOAD s3, 01 |
16#03C# => opSubR & "0001" & "0000----", -- SUB s1, s0 ; 03 |
16#03D# => opSubCyR & "0001" & "0010----", -- SUBCY s1, s2 ; 113 |
16#03E# => opSubCyR & "0001" & "0010----", -- SUBCY s1, s2 ; 22 |
16#03F# => opSubR & "0001" & "0011----", -- SUB s1, s3 ; 21 |
16#040# => opCompC & "0001" & "00100001", -- COMPARE s1, 21 |
16#041# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 5) Test shifts |
----------------------------------------------------------------- |
16#042# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test shift right |
----------------------------------------------------------------- |
16#043# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F ; 0F |
16#044# => opShRot & "0000" & shRotR & shRotLd0,-- SR0 s0 ; 07 |
16#045# => opShRot & "0000" & shRotR & shRotLdM,-- SRX s0 ; 03 |
16#046# => opShRot & "0000" & shRotR & shRotLd1,-- SR1 s0 ; 81 |
16#047# => opShRot & "0000" & shRotR & shRotLdM,-- SRX s0 ; C0, C=1 |
16#048# => opShRot & "0000" & shRotR & shRotLdC,-- SRA s0 ; E0, C=0 |
16#049# => opShRot & "0000" & shRotR & shRotLdC,-- SRA s0 ; 70 |
16#04A# => opCompC & "0000" & "01110000", -- COMPARE s0, 70 |
16#04B# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test shift left |
----------------------------------------------------------------- |
16#04C# => opLoadC & "0001" & "11110000", -- LOAD s1, F0 ; FO |
16#04D# => opShRot & "0001" & shRotL & shRotLd0,-- SL0 s1 ; E0 |
16#04E# => opShRot & "0001" & shRotL & shRotLdL,-- SLX s1 ; C0 |
16#04F# => opShRot & "0001" & shRotL & shRotLd1,-- SL1 s1 ; 81 |
16#050# => opShRot & "0001" & shRotL & shRotLdL,-- SLX s1 ; 03, C=1 |
16#051# => opShRot & "0001" & shRotL & shRotLdC,-- SLA s1 ; 07, C=0 |
16#052# => opShRot & "0001" & shRotL & shRotLdC,-- SLA s1 ; 0E |
16#053# => opCompC & "0001" & "00001110", -- COMPARE s1, 0E |
16#054# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 6) Test comparison operators |
----------------------------------------------------------------- |
16#055# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "COMPARE" |
----------------------------------------------------------------- |
16#056# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#057# => opCompC & "0000" & "11110000", -- COMPARE s0, F0 ; A < B => C=1 |
16#058# => brJump & brNC & "1111111101", -- JUMP NC, 3FD |
16#059# => opCompC & "0000" & "11110000", -- COMPARE s0, F0 ; A < B => Z=0 |
16#05A# => brJump & brZ & "1111111101", -- JUMP Z, 3FD |
16#05B# => opCompR & "0000" & "0000----", -- COMPARE s0, s0 ; A = B => Z=1 |
16#05C# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
16#05D# => opCompC & "0000" & "00001000", -- COMPARE s0, 08 ; A > B => C=0 |
16#05E# => brJump & brC & "1111111101", -- JUMP C, 3FD |
16#05F# => opCompC & "0000" & "00001000", -- COMPARE s0, 08 ; A > B => Z=0 |
16#060# => brJump & brZ & "1111111101", -- JUMP Z, 3FD |
----------------------------------------------------------------- |
-- Test "TEST" |
----------------------------------------------------------------- |
16#061# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#062# => opTestC & "0000" & "11110000", -- TEST s0, F0 ; AND is 00 => Z=1 |
16#063# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
16#064# => opTestC & "0000" & "11111111", -- TEST s0, FF ; AND is 0F => Z=0 |
16#065# => brJump & brZ & "1111111101", -- JUMP Z, 3FD |
--=============================================================== |
-- 7) Test INPUT and OUTPUT operators |
----------------------------------------------------------------- |
16#066# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "INPUT" and "OUTPUT" direct |
-- |
-- The testbench should invert the word written at address FC. |
----------------------------------------------------------------- |
16#067# => opLoadC & "0000" & "10101010", -- LOAD s0, AA |
16#068# => opOutputC & "0000" & "11111100", -- OUTPUT s0, FC |
16#069# => opInputC & "0001" & "11111100", -- INPUT s1, FC |
16#06A# => opCompC & "0001" & "01010101", -- COMPARE s1, 55 |
16#06B# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "INPUT" and "OUTPUT" indexed |
----------------------------------------------------------------- |
16#06C# => opLoadC & "0000" & "11001100", -- LOAD s0, CC |
16#06D# => opLoadC & "0010" & "11111100", -- LOAD s2, FC |
16#06E# => opOutputR & "0000" & "0010----", -- OUTPUT s0, (S2) |
16#06F# => opInputR & "0001" & "0010----", -- INPUT s1, (S2) |
16#070# => opCompC & "0001" & "00110011", -- COMPARE s1, 33 |
16#071# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 8) Test STORE and FETCH operators |
----------------------------------------------------------------- |
16#072# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "STORE" and "FETCH" direct |
----------------------------------------------------------------- |
16#073# => opLoadC & "0000" & "00001111", -- LOAD s0, 0F |
16#074# => opStoreC & "0000" & "00000011", -- STORE s0, 03 |
16#075# => opFetchC & "0001" & "00000011", -- FETCH s1, 03 |
16#076# => opCompC & "0001" & "00001111", -- COMPARE s1, 0F |
16#077# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
----------------------------------------------------------------- |
-- Test "STORE" and "FETCH" indexed |
----------------------------------------------------------------- |
16#078# => opLoadC & "0000" & "11110000", -- LOAD s0, F0 |
16#079# => opLoadC & "0010" & "00000100", -- LOAD s2, 04 |
16#07A# => opStoreR & "0000" & "0010----", -- STORE s0, (S2) |
16#07B# => opFetchR & "0001" & "0010----", -- FETCH s1, (S2) |
16#07C# => opCompC & "0001" & "11110000", -- COMPARE s1, F0 |
16#07D# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 9) Test JUMP instructions |
----------------------------------------------------------------- |
16#07E# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- Test "JUMP NC" |
----------------------------------------------------------------- |
16#07F# => opLoadC & "0000" & "11110000", -- LOAD s0, F0 |
16#080# => opAddC & "0000" & "00000000", -- ADD s0, 00 ; s0=F0, C=0, Z=0 |
16#081# => brJump & brNC & "0010000011", -- JUMP NC, 083 |
16#082# => brJump & brDo & "1111111101", -- JUMP 3FD |
----------------------------------------------------------------- |
-- Test "JUMP NZ" |
----------------------------------------------------------------- |
-- _continue1_: |
16#083# => opAddC & "0000" & "00000000", -- ADD s0, 00 ; s0=F0, C=0, Z=0 |
16#084# => brJump & brNZ & "0010000110", -- JUMP NZ, 086 |
16#085# => brJump & brDo & "1111111101", -- JUMP 3FD |
----------------------------------------------------------------- |
-- Test "JUMP C" |
----------------------------------------------------------------- |
-- _continue2_: |
16#086# => opAddC & "0000" & "11110000", -- ADD s0, F0 ; s0=E0, C=1, Z=0 |
16#087# => brJump & brC & "0010001001", -- JUMP C, 089 |
16#088# => brJump & brDo & "1111111101", -- JUMP 3FD |
----------------------------------------------------------------- |
-- Test "JUMP Z" |
----------------------------------------------------------------- |
-- _continue3_: |
16#089# => opSubC & "0000" & "11100000", -- SUB s0, E0 ; s0=00, C=0, Z=1 |
16#08A# => brJump & brZ & "0010001100", -- JUMP Z, 08C |
16#08B# => brJump & brDo & "1111111101", -- JUMP 3FD |
-- _continue4_: |
16#08C# => opLoadR & "0000" & "0000----", -- NOP |
--=============================================================== |
-- 10) Test call instructions |
----------------------------------------------------------------- |
16#08D# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- define subroutine |
----------------------------------------------------------------- |
16#08E# => brJump & brDo & "0010010010", -- JUMP 092 |
-- _subRetDo_: |
16#08F# => opAddC & "0000" & "00000001", -- ADD s0, 01 |
16#090# => brRet & brDo & "----------", -- RETURN |
16#091# => brJump & brDo & "1111111101", -- JUMP 3FD |
----------------------------------------------------------------- |
-- Test "CALL" |
----------------------------------------------------------------- |
-- _continue5_: |
16#092# => opLoadC & "0000" & "00000000", -- LOAD s0, 00 |
16#093# => opLoadC & "0001" & "11110000", -- LOAD s1, F0 |
16#094# => brCall & brDo & "0010001111", -- CALL 08F ; s0=01 |
----------------------------------------------------------------- |
-- Test "CALL NC" |
----------------------------------------------------------------- |
16#095# => opAddC & "0001" & "00000000", -- ADD s1, 00 ; s1=F0, C=0, Z=0 |
16#096# => brCall & brNC & "0010001111", -- CALL NC, 08F ; s0=02 |
----------------------------------------------------------------- |
-- Test "CALL NZ" |
----------------------------------------------------------------- |
16#097# => opAddC & "0001" & "00000000", -- ADD s1, 00 ; s1=F0, C=0, Z=0 |
16#098# => brCall & brNZ & "0010001111", -- CALL NZ, 08F ; s0=03 |
----------------------------------------------------------------- |
-- Test "CALL C" |
----------------------------------------------------------------- |
16#099# => opAddC & "0001" & "11110000", -- ADD s1, F0 ; s0=E0, C=1, Z=0 |
16#09A# => brCall & brC & "0010001111", -- CALL C, 08F ; s0=04 |
----------------------------------------------------------------- |
-- Test "CALL Z" |
----------------------------------------------------------------- |
16#09B# => opSubC & "0001" & "11100000", -- SUB s1, E0 ; s0=00, C=0, Z=1 |
16#09C# => brCall & brZ & "0010001111", -- CALL Z, 08F ; s0=05 |
16#09D# => opCompC & "0000" & "00000101", -- COMPARE s0, 05 |
16#09E# => brJump & brNZ & "1111111101", -- JUMP NZ, 3FD |
--=============================================================== |
-- 11) Test call return instructions |
----------------------------------------------------------------- |
16#09F# => opAddC & "0111" & "00000001", -- ADD s7, 01 |
----------------------------------------------------------------- |
-- define subroutines |
----------------------------------------------------------------- |
16#0A0# => brJump & brDo & "0010101101", -- JUMP 0AD |
-- _subRetNC_: |
16#0A1# => opAddC & "0000" & "00000001", -- ADD s0, 01 |
16#0A2# => brRet & brDo & "----------", -- RETURN NC |
16#0A3# => brJump & brDo & "1111111101", -- JUMP 3FD |
-- _subRetNZ_: |
16#0A4# => opAddC & "0000" & "00000001", -- ADD s0, 01 |
16#0A5# => brRet & brDo & "----------", -- RETURN NZ |
16#0A6# => brJump & brDo & "1111111101", -- JUMP 3FD |
-- _subRetC_: |
16#0A7# => opAddC & "0000" & "00000001", -- ADD s0, 01 |
16#0A8# => brRet & brDo & "----------", -- RETURN C |
16#0A9# => brJump & brDo & "1111111101", -- JUMP 3FD |
-- _subRetZ_: |
16#0AA# => opAddC & "0000" & "00000001", -- ADD s0, 01 |
16#0AB# => brRet & brDo & "----------", -- RETURN Z |
16#0AC# => brJump & brDo & "1111111101", -- JUMP 3FD |
----------------------------------------------------------------- |
-- Test "RETURN NC" |
----------------------------------------------------------------- |
-- _continue6_: |
16#0AD# => opLoadC & "0000" & "00000000", -- LOAD s0, 00 ; increment will give C=0, Z=0 |
16#0AE# => brCall & brNC & "0010100001", -- CALL NC, 0A1 |
----------------------------------------------------------------- |
-- Test "RETURN NZ" |
----------------------------------------------------------------- |
16#0AF# => opLoadC & "0000" & "00000000", -- LOAD s0, 00 ; increment will give C=0, Z=0 |
16#0B0# => brCall & brNZ & "0010100100", -- CALL NZ, 0A4 |
----------------------------------------------------------------- |
-- Test "RETURN C" |
----------------------------------------------------------------- |
16#0B1# => opLoadC & "0000" & "11111111", -- LOAD s0, FF ; increment will give C=1, Z=1 |
16#0B2# => brCall & brC & "0010100111", -- CALL C, 0A7 |
----------------------------------------------------------------- |
-- Test "RETURN Z" |
----------------------------------------------------------------- |
16#0B3# => opLoadC & "0000" & "11111111", -- LOAD s0, FF ; increment will give C=1, Z=1 |
16#0B4# => brCall & brZ & "0010101010", -- CALL Z, 0AA |
--=============================================================== |
-- End of tests |
-- |
-- The testbench should react if value 1 is written to address 00. |
----------------------------------------------------------------- |
16#0B5# => opLoadC & "0000" & "00000001", -- LOAD s0, 01 |
16#0B6# => opOutputC & "0000" & "00000000", -- OUTPUT s0, 00 |
16#0B7# => brJump & brDo & "1111111111", -- JUMP 3FF |
--=============================================================== |
-- Assert error |
-- |
-- The testbench should react if value 0 is written to address 00. |
----------------------------------------------------------------- |
-- _error_: |
16#3FD# => opLoadC & "0000" & "00000000", -- LOAD s0, 00 |
16#3FE# => opOutputC & "0000" & "00000000", -- OUTPUT s0, 00 |
--=============================================================== |
-- End of instruction memory |
----------------------------------------------------------------- |
-- _endOfMemory_: |
16#3FF# => brJump & brDo & "1111111111", -- JUMP 3FF |
others => (others => '0') |
); |
|
BEGIN |
|
process (clock) |
begin |
if rising_edge(clock) then |
if en = '1' then |
dataOut <= memoryArray(to_integer(address)); |
end if; |
end if; |
end process; |
|
END ARCHITECTURE mapped; |
trunk/Circuit/programRom.vhd
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/Circuit/nanoProcessor.vhd
===================================================================
--- trunk/Circuit/nanoProcessor.vhd (nonexistent)
+++ trunk/Circuit/nanoProcessor.vhd (revision 8)
@@ -0,0 +1,564 @@
+--##############################################################################
+--
+-- nanoProcessor
+-- Processor core
+--
+-- This describes the processor core, without the instruction ROM.
+--
+--------------------------------------------------------------------------------
+--
+-- Versions / Authors
+-- 1.0 Francois Corthay first implementation
+--
+-- Provided under GNU LGPL licence:
+--
+-- by the electronics group of "HES-SO//Valais Wallis", in Switzerland:
+-- .
+--
+--------------------------------------------------------------------------------
+--
+-- Hierarchy
+-- Used by "nanoblaze".
+--
+--##############################################################################
+
+LIBRARY ieee;
+ USE ieee.std_logic_1164.all;
+ USE ieee.numeric_std.all;
+
+ENTITY nanoProcessor IS
+ GENERIC(
+ addressBitNb : positive := 8;
+ registerBitNb : positive := 8;
+ registerAddressBitNb : positive := 4;
+ programCounterBitNb : positive := 10;
+ stackPointerBitNb : positive := 5;
+ instructionBitNb : positive := 18;
+ scratchpadAddressBitNb : natural := 4
+ );
+ PORT(
+ reset => reset,
+ clock => clock,
+ en => en,
+ progCounter => programCounter,
+ instruction => instruction,
+ dataAddress => dataAddress,
+ dataOut => dataOut,
+ dataIn => dataIn,
+ readStrobe => readStrobe,
+ writeStrobe => writeStrobe,
+ int => int,
+ intAck => intAck
+ );
+END nanoProcessor ;
+
+--==============================================================================
+
+ARCHITECTURE struct OF nanoProcessor IS
+
+ constant aluCodeBitNb: positive := 5;
+ constant opCodeBitNb: positive := 5;
+ constant branchCondBitNb: positive := 3;
+ constant intCodeBitNb: positive := 5;
+
+ SIGNAL addrA : unsigned(registerAddressBitNb-1 DOWNTO 0);
+ SIGNAL addrB : unsigned(registerAddressBitNb-1 DOWNTO 0);
+ SIGNAL aluCode : std_ulogic_vector(aluCodeBitNb-1 DOWNTO 0);
+ SIGNAL branchCond : std_ulogic_vector(branchCondBitNb-1 DOWNTO 0);
+ SIGNAL cIn : std_ulogic;
+ SIGNAL cOut : std_ulogic;
+ SIGNAL incPC : std_ulogic;
+ SIGNAL instrAddress : unsigned(programCounterBitNb-1 DOWNTO 0);
+ SIGNAL instrData : signed(registerBitNb-1 DOWNTO 0);
+ SIGNAL instrDataSel : std_ulogic;
+ SIGNAL instrString : string(1 TO 16);
+ SIGNAL intCode : std_ulogic_vector(intCodeBitNb-1 DOWNTO 0);
+ SIGNAL loadInstrAddress : std_ulogic;
+ SIGNAL loadStoredPC : std_ulogic;
+ SIGNAL opCode : std_ulogic_vector(opCodeBitNb-1 DOWNTO 0);
+ SIGNAL portIn : signed(registerBitNb-1 DOWNTO 0);
+ SIGNAL portInSel : std_ulogic;
+ SIGNAL portIndexedSel : std_ulogic;
+ SIGNAL portInstrAddress : unsigned(addressBitNb-1 DOWNTO 0);
+ SIGNAL portOut : signed(registerBitNb-1 DOWNTO 0);
+ SIGNAL portRegAddress : unsigned(addressBitNb-1 DOWNTO 0);
+ SIGNAL prevPC : std_ulogic;
+ SIGNAL regWrite : std_ulogic;
+ SIGNAL registerFileSel : std_ulogic;
+ SIGNAL scratchpadSel : std_ulogic;
+ SIGNAL scratchpadWrite : std_ulogic;
+ SIGNAL spadAddress : unsigned(scratchpadAddressBitNb-1 DOWNTO 0);
+ SIGNAL spadIn : signed(registerBitNb-1 DOWNTO 0);
+ SIGNAL spadIndexedSel : std_ulogic;
+ SIGNAL spadInstrAddress : unsigned(scratchpadAddressBitNb-1 DOWNTO 0);
+ SIGNAL spadOut : signed(registerBitNb-1 DOWNTO 0);
+ SIGNAL spadRegAddress : unsigned(scratchpadAddressBitNb-1 DOWNTO 0);
+ SIGNAL storePC : std_ulogic;
+ SIGNAL storedProgCounter : unsigned(programCounterBitNb-1 DOWNTO 0);
+ SIGNAL twoRegInstr : std_ulogic;
+ SIGNAL zero : std_ulogic;
+
+ SIGNAL progCounter_int : unsigned(progCounter'range);
+
+ COMPONENT aluAndRegs
+ GENERIC (
+ registerBitNb : positive := 8;
+ registerAddressBitNb : positive := 4;
+ aluCodeBitNb : positive := 5;
+ portAddressBitNb : positive := 8;
+ scratchpadAddressBitNb : natural := 4
+ );
+ PORT (
+ addrA : IN unsigned(registerAddressBitNb-1 DOWNTO 0);
+ addrB : IN unsigned(registerAddressBitNb-1 DOWNTO 0);
+ aluCode : IN std_ulogic_vector(aluCodeBitNb-1 DOWNTO 0);
+ cIn : IN std_ulogic;
+ clock : IN std_ulogic;
+ instrData : IN signed(registerBitNb-1 DOWNTO 0);
+ instrDataSel : IN std_ulogic;
+ portIn : IN signed(registerBitNb-1 DOWNTO 0);
+ portInSel : IN std_ulogic;
+ regWrite : IN std_ulogic;
+ registerFileSel : IN std_ulogic;
+ reset : IN std_ulogic;
+ scratchpadSel : IN std_ulogic;
+ spadIn : IN signed(registerBitNb-1 DOWNTO 0);
+ cOut : OUT std_ulogic;
+ portAddr : OUT unsigned(portAddressBitNb-1 DOWNTO 0);
+ portOut : OUT signed(registerBitNb-1 DOWNTO 0);
+ scratchpadAddr : OUT unsigned(scratchpadAddressBitNb-1 DOWNTO 0);
+ spadOut : OUT signed(registerBitNb-1 DOWNTO 0);
+ zero : OUT std_ulogic
+ );
+ END COMPONENT;
+
+ COMPONENT branchStack
+ GENERIC (
+ programCounterBitNb : positive := 10;
+ stackPointerBitNb : positive := 5
+ );
+ PORT (
+ clock : IN std_ulogic;
+ prevPC : IN std_ulogic;
+ progCounter : IN unsigned(programCounterBitNb-1 DOWNTO 0);
+ reset : IN std_ulogic;
+ storePC : IN std_ulogic;
+ storedProgCounter : OUT unsigned(programCounterBitNb-1 DOWNTO 0 )
+ );
+ END COMPONENT;
+
+ COMPONENT controller
+ GENERIC (
+ intCodeBitNb : positive := 5;
+ branchCondBitNb : positive := 3;
+ opCodeBitNb : positive := 5
+ );
+ PORT (
+ branchCond : IN std_ulogic_vector(branchCondBitNb-1 DOWNTO 0);
+ cOut : IN std_ulogic;
+ clock : IN std_ulogic;
+ en : IN std_ulogic;
+ int : IN std_ulogic;
+ intCode : IN std_ulogic_vector(intCodeBitNb-1 DOWNTO 0);
+ opCode : IN std_ulogic_vector(opCodeBitNb-1 DOWNTO 0);
+ reset : IN std_ulogic;
+ twoRegInstr : IN std_ulogic;
+ zero : IN std_ulogic;
+ cIn : OUT std_ulogic;
+ incPC : OUT std_ulogic;
+ instrDataSel : OUT std_ulogic;
+ intAck : OUT std_ulogic;
+ loadInstrAddress : OUT std_ulogic;
+ loadStoredPC : OUT std_ulogic;
+ portInSel : OUT std_ulogic;
+ prevPC : OUT std_ulogic;
+ readStrobe : OUT std_ulogic;
+ regWrite : OUT std_ulogic;
+ registerFileSel : OUT std_ulogic;
+ scratchpadSel : OUT std_ulogic;
+ scratchpadWrite : OUT std_ulogic;
+ storePC : OUT std_ulogic;
+ writeStrobe : OUT std_uLogic
+ );
+ END COMPONENT;
+
+ COMPONENT instructionDecoder
+ GENERIC (
+ registerBitNb : positive := 8;
+ registerAddressBitNb : positive := 4;
+ aluCodeBitNb : positive := 5;
+ instructionBitNb : positive := 18;
+ programCounterBitNb : positive := 10;
+ opCodeBitNb : positive := 5;
+ branchCondBitNb : positive := 3;
+ intCodeBitNb : positive := 5;
+ spadAddressBitNb : natural := 4;
+ portAddressBitNb : positive := 8
+ );
+ PORT (
+ instruction : IN std_ulogic_vector(instructionBitNb-1 DOWNTO 0);
+ addrA : OUT unsigned(registerAddressBitNb-1 DOWNTO 0);
+ addrB : OUT unsigned(registerAddressBitNb-1 DOWNTO 0);
+ aluCode : OUT std_ulogic_vector(aluCodeBitNb-1 DOWNTO 0);
+ branchCond : OUT std_ulogic_vector(branchCondBitNb-1 DOWNTO 0);
+ instrAddress : OUT unsigned(programCounterBitNb-1 DOWNTO 0);
+ instrData : OUT signed(registerBitNb-1 DOWNTO 0);
+ intCode : OUT std_ulogic_vector(intCodeBitNb-1 DOWNTO 0);
+ opCode : OUT std_ulogic_vector(opCodeBitNb-1 DOWNTO 0);
+ portAddress : OUT unsigned(portAddressBitNb-1 DOWNTO 0);
+ portIndexedSel : OUT std_ulogic;
+ spadAddress : OUT unsigned(spadAddressBitNb-1 DOWNTO 0);
+ spadIndexedSel : OUT std_ulogic;
+ twoRegInstr : OUT std_ulogic
+ );
+ END COMPONENT;
+
+ COMPONENT programCounter
+ GENERIC (
+ programCounterBitNb : positive := 10
+ );
+ PORT (
+ clock : IN std_ulogic;
+ incPC : IN std_ulogic;
+ instrAddress : IN unsigned(programCounterBitNb-1 DOWNTO 0);
+ loadInstrAddress : IN std_ulogic;
+ loadStoredPC : IN std_ulogic;
+ reset : IN std_ulogic;
+ storedProgCounter : IN unsigned(programCounterBitNb-1 DOWNTO 0);
+ progCounter : OUT unsigned(programCounterBitNb-1 DOWNTO 0 )
+ );
+ END COMPONENT;
+
+ COMPONENT scratchpad
+ GENERIC (
+ registerBitNb : positive := 8;
+ spadAddressBitNb : natural := 4
+ );
+ PORT (
+ addr : IN unsigned(spadAddressBitNb-1 DOWNTO 0);
+ clock : IN std_ulogic;
+ dataIn : IN signed(registerBitNb-1 DOWNTO 0);
+ reset : IN std_ulogic;
+ write : IN std_ulogic;
+ dataOut : OUT signed(registerBitNb-1 DOWNTO 0 )
+ );
+ END COMPONENT;
+
+BEGIN
+ I_alu : aluAndRegs
+ GENERIC MAP (
+ registerBitNb => registerBitNb,
+ registerAddressBitNb => registerAddressBitNb,
+ aluCodeBitNb => aluCodeBitNb,
+ portAddressBitNb => addressBitNb,
+ scratchpadAddressBitNb => scratchpadAddressBitNb
+ )
+ PORT MAP (
+ addrA => addrA,
+ addrB => addrB,
+ aluCode => aluCode,
+ cIn => cIn,
+ clock => clock,
+ instrData => instrData,
+ instrDataSel => instrDataSel,
+ portIn => portIn,
+ portInSel => portInSel,
+ regWrite => regWrite,
+ registerFileSel => registerFileSel,
+ reset => reset,
+ scratchpadSel => scratchpadSel,
+ spadIn => spadIn,
+ cOut => cOut,
+ portAddr => portRegAddress,
+ portOut => portOut,
+ scratchpadAddr => spadRegAddress,
+ spadOut => spadOut,
+ zero => zero
+ );
+
+ I_BR : branchStack
+ GENERIC MAP (
+ programCounterBitNb => programCounterBitNb,
+ stackPointerBitNb => stackPointerBitNb
+ )
+ PORT MAP (
+ clock => clock,
+ prevPC => prevPC,
+ progCounter => progCounter_int,
+ reset => reset,
+ storePC => storePC,
+ storedProgCounter => storedProgCounter
+ );
+
+ I_ctrl : controller
+ GENERIC MAP (
+ intCodeBitNb => 5,
+ branchCondBitNb => branchCondBitNb,
+ opCodeBitNb => opCodeBitNb
+ )
+ PORT MAP (
+ branchCond => branchCond,
+ cOut => cOut,
+ clock => clock,
+ en => en,
+ int => int,
+ intCode => intCode,
+ opCode => opCode,
+ reset => reset,
+ twoRegInstr => twoRegInstr,
+ zero => zero,
+ cIn => cIn,
+ incPC => incPC,
+ instrDataSel => instrDataSel,
+ intAck => intAck,
+ loadInstrAddress => loadInstrAddress,
+ loadStoredPC => loadStoredPC,
+ portInSel => portInSel,
+ prevPC => prevPC,
+ readStrobe => readStrobe,
+ regWrite => regWrite,
+ registerFileSel => registerFileSel,
+ scratchpadSel => scratchpadSel,
+ scratchpadWrite => scratchpadWrite,
+ storePC => storePC,
+ writeStrobe => writeStrobe
+ );
+
+ I_instr : instructionDecoder
+ GENERIC MAP (
+ registerBitNb => registerBitNb,
+ registerAddressBitNb => registerAddressBitNb,
+ aluCodeBitNb => aluCodeBitNb,
+ instructionBitNb => instructionBitNb,
+ programCounterBitNb => programCounterBitNb,
+ opCodeBitNb => opCodeBitNb,
+ branchCondBitNb => branchCondBitNb,
+ intCodeBitNb => 5,
+ spadAddressBitNb => scratchpadAddressBitNb,
+ portAddressBitNb => addressBitNb
+ )
+ PORT MAP (
+ instruction => instruction,
+ addrA => addrA,
+ addrB => addrB,
+ aluCode => aluCode,
+ branchCond => branchCond,
+ instrAddress => instrAddress,
+ instrData => instrData,
+ intCode => intCode,
+ opCode => opCode,
+ portAddress => portInstrAddress,
+ portIndexedSel => portIndexedSel,
+ spadAddress => spadInstrAddress,
+ spadIndexedSel => spadIndexedSel,
+ twoRegInstr => twoRegInstr
+ );
+
+ I_PC : programCounter
+ GENERIC MAP (
+ programCounterBitNb => programCounterBitNb
+ )
+ PORT MAP (
+ clock => clock,
+ incPC => incPC,
+ instrAddress => instrAddress,
+ loadInstrAddress => loadInstrAddress,
+ loadStoredPC => loadStoredPC,
+ reset => reset,
+ storedProgCounter => storedProgCounter,
+ progCounter => progCounter_int
+ );
+
+ generate_scratchpad: IF scratchpadAddressBitNb > 0 GENERATE
+ BEGIN
+ I_sPad : scratchpad
+ GENERIC MAP (
+ registerBitNb => registerBitNb,
+ spadAddressBitNb => scratchpadAddressBitNb
+ )
+ PORT MAP (
+ addr => spadAddress,
+ clock => clock,
+ dataIn => spadOut,
+ reset => reset,
+ write => scratchpadWrite,
+ dataOut => spadIn
+ );
+ END GENERATE generate_scratchpad;
+
+ portIn <= signed(dataIn);
+ dataAddress <= portInstrAddress when portIndexedSel = '0' else portRegAddress;
+ dataOut <= std_ulogic_vector(portOut);
+ spadAddress <= spadInstrAddress when spadIndexedSel = '0' else spadRegAddress;
+
+ progCounter <= progCounter_int;
+
+ ------------------------------------------------------------------------------
+ -- disassembler: reads "instruction" and writes "instrString"
+ --
+ -- pragma translate_off
+ process(instruction)
+
+ constant bitsPerHexDigit : positive := 4;
+
+ function pad(inString : string; outLength : positive) return string is
+ variable outString : string(1 to outLength);
+ begin
+ outString := (others => ' ');
+ outString(inString'range) := inString;
+ return outString;
+ end function pad;
+
+ function hexDigitNb(bitNb : positive) return positive is
+ begin
+ return (bitNb-1)/bitsPerHexDigit+1;
+ end function hexDigitNb;
+
+ variable opCode : unsigned(1+opCodeBitNb-1 downto 0);
+ variable destRegister : unsigned(registerAddressBitNb-1 downto 0);
+ variable destRegisterString : string(1 to 1+hexDigitNb(registerAddressBitNb));
+ variable sourceRegister : unsigned(registerAddressBitNb-1 downto 0);
+ variable sourceRegisterString : string(1 to 1+hexDigitNb(registerAddressBitNb));
+ variable sourceConstant : unsigned(registerBitNb-1 downto 0);
+ variable sourceConstantString : string(1 to hexDigitNb(registerBitNb));
+ variable branchAddress : unsigned(programCounterBitNb-1 downto 0);
+ variable branchAddressString : string(1 to hexDigitNb(programCounterBitNb));
+ variable branchKind : unsigned(1 downto 0);
+ variable shRotCin : unsigned(2 downto 0);
+ variable shRotDir: std_ulogic;
+
+ function toHexDigit(binary : unsigned(bitsPerHexDigit-1 downto 0)) return character is
+ begin
+ if binary <= 9 then
+ return character'val(character'pos('0') + to_integer(to_01(binary)));
+ else
+ return character'val(character'pos('A') + to_integer(to_01(binary)) - 10);
+ end if;
+ end function toHexDigit;
+
+ function toHexString(binary : unsigned) return string is
+ variable hexString : string(1 to hexDigitNb(binary'length));
+ begin
+ for index in hexString'high-1 downto 0 loop
+ hexString(hexString'high-index) := toHexDigit(
+ resize(shift_right(binary, bitsPerHexDigit*index), bitsPerHexDigit)
+ );
+ end loop;
+ return hexString;
+ end function toHexString;
+
+ begin
+
+ opCode := resize(
+ shift_right(unsigned(instruction), instruction'length-opCode'length),
+ opCode'length
+ );
+ destRegister := resize(
+ shift_right(unsigned(instruction), instruction'length-opCode'length-destRegister'length),
+ destRegister'length
+ );
+ destRegisterString := 's' & toHexDigit(destRegister);
+ sourceRegister := resize(
+ shift_right(unsigned(instruction), instruction'length-opCode'length-destRegister'length-sourceRegister'length),
+ sourceRegister'length
+ );
+ sourceRegisterString := 's' & toHexDigit(sourceRegister);
+ sourceConstant := resize(unsigned(instruction), sourceConstant'length);
+ sourceConstantString := toHexString(sourceConstant);
+ branchKind := resize(
+ shift_right(unsigned(instruction), instruction'length-opCode'length-branchKind'length),
+ branchKind'length
+ );
+ branchAddress := resize(unsigned(instruction), branchAddress'length);
+ branchAddressString := toHexString(branchAddress);
+ shRotCin := resize(shift_right(unsigned(instruction), 1), shRotCin'length);
+ shRotDir := instruction(0);
+
+ case opCode is
+ when "000000" => instrString <= pad("LOAD " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "000001" => instrString <= pad("LOAD " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "000100" => instrString <= pad("INPUT " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "000101" => instrString <= pad("INPUT " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "000110" => instrString <= pad("FETCH " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "000111" => instrString <= pad("FETCH " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "001010" => instrString <= pad("AND " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "001011" => instrString <= pad("AND " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "001100" => instrString <= pad("OR " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "001101" => instrString <= pad("OR " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "001110" => instrString <= pad("XOR " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "001111" => instrString <= pad("XOR " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "010010" => instrString <= pad("TEST " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "010011" => instrString <= pad("TEST " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "010100" => instrString <= pad("COMP " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "010101" => instrString <= pad("COMP " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "011000" => instrString <= pad("ADD " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "011001" => instrString <= pad("ADD " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "011010" => instrString <= pad("ADDCY " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "011011" => instrString <= pad("ADDCY " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "011100" => instrString <= pad("SUB " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "011101" => instrString <= pad("SUB " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "011110" => instrString <= pad("SUBCY " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "011111" => instrString <= pad("SUBCY " & destRegisterString & " " & sourceRegisterString, instrString'length);
+ when "100000" =>
+ case shRotCin is
+ when "000" => instrString <= pad("SLA " & destRegisterString, instrString'length);
+ when "001" => instrString <= pad("RL " & destRegisterString, instrString'length);
+ when "010" => instrString <= pad("SLX " & destRegisterString, instrString'length);
+ when "011" =>
+ case shRotDir is
+ when '0' => instrString <= pad("SL0 " & destRegisterString, instrString'length);
+ when '1' => instrString <= pad("SL1 " & destRegisterString, instrString'length);
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+ when "100" => instrString <= pad("SRA " & destRegisterString, instrString'length);
+ when "101" => instrString <= pad("SRX " & destRegisterString, instrString'length);
+ when "110" => instrString <= pad("RR " & destRegisterString, instrString'length);
+ when "111" =>
+ case shRotDir is
+ when '0' => instrString <= pad("SR0 " & destRegisterString, instrString'length);
+ when '1' => instrString <= pad("SR1 " & destRegisterString, instrString'length);
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+ when "101100" => instrString <= pad("OUTPUT " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "101101" => instrString <= pad("OUTPUT " & destRegisterString & " (" & sourceRegisterString & ")", instrString'length);
+ when "101110" => instrString <= pad("STORE " & destRegisterString & " " & sourceConstantString, instrString'length);
+ when "101111" => instrString <= pad("STORE " & destRegisterString & " (" & sourceRegisterString & ")", instrString'length);
+ when "101010" => instrString <= pad("RET", instrString'length);
+ when "101011" =>
+ case branchKind is
+ when "00" => instrString <= pad("RET Z", instrString'length);
+ when "01" => instrString <= pad("RET NZ", instrString'length);
+ when "10" => instrString <= pad("RET C", instrString'length);
+ when "11" => instrString <= pad("RET NC", instrString'length);
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+ when "110000" => instrString <= pad("CALL " & branchAddressString, instrString'length);
+ when "110001" =>
+ case branchKind is
+ when "00" => instrString <= pad("CALL Z " & branchAddressString, instrString'length);
+ when "01" => instrString <= pad("CALL NZ " & branchAddressString, instrString'length);
+ when "10" => instrString <= pad("CALL C " & branchAddressString, instrString'length);
+ when "11" => instrString <= pad("CALL NC " & branchAddressString, instrString'length);
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+ when "110100" => instrString <= pad("JUMP " & branchAddressString, instrString'length);
+ when "110101" =>
+ case branchKind is
+ when "00" => instrString <= pad("JUMP Z " & branchAddressString, instrString'length);
+ when "01" => instrString <= pad("JUMP NZ " & branchAddressString, instrString'length);
+ when "10" => instrString <= pad("JUMP C " & branchAddressString, instrString'length);
+ when "11" => instrString <= pad("JUMP NC " & branchAddressString, instrString'length);
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+ when others => instrString <= pad("--------", instrString'length);
+ end case;
+
+ end process;
+ -- pragma translate_on
+ --
+ -- end of disassembler
+ ------------------------------------------------------------------------------
+
+END ARCHITECTURE struct;
trunk/Circuit/nanoProcessor.vhd
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property