tisc

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 5294e6e028f2d2b4b38f36aa89f40b0c6d685933
parent 16c088799e69a26d1a93990c71ca79a46bf456bf
Author: paul_longtine <paul.longtine@signal-fire.com>
Date:   Sat, 28 Sep 2019 00:55:47 -0400

Modularized the logisim implementation of TISC, added a null GPR token in the assembler and re-worded and clarified the INSTRUCTION_SET document

Diffstat:
MCPU/CPU.circ | 235++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
MINSTRUCTION_SET | 56++++++++++++++++++++++++++++++++++++++++----------------
Mtisc.c | 6++++++
3 files changed, 200 insertions(+), 97 deletions(-)

diff --git a/CPU/CPU.circ b/CPU/CPU.circ @@ -63,183 +63,189 @@ This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). <a name="clabel" val=""/> <a name="clabelup" val="east"/> <a name="clabelfont" val="SansSerif plain 12"/> - <wire from="(600,440)" to="(600,450)"/> + <appear> + <path d="M53,12 Q57,22 61,12" fill="none" stroke="#808080" stroke-width="2"/> + <rect fill="none" height="120" stroke="#000000" stroke-width="2" width="120" x="40" y="11"/> + <rect fill="#707070" height="120" stroke="#000000" width="120" x="40" y="10"/> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="101" y="126">tisc v1.0</text> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="153" y="23">INPUT_ENABLE</text> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="151" y="42">INPUT</text> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="153" y="62">ADDRESS</text> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="154" y="82">OUTPUT</text> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="155" y="103">CLK</text> + <text fill="#fafafa" font-family="Consolas" font-size="10" text-anchor="end" x="154" y="122">RST</text> + <circ-port height="8" pin="480,340" width="8" x="156" y="16"/> + <circ-port height="8" pin="420,360" width="8" x="156" y="36"/> + <circ-port height="10" pin="420,380" width="10" x="155" y="55"/> + <circ-port height="10" pin="420,400" width="10" x="155" y="75"/> + <circ-port height="8" pin="480,420" width="8" x="156" y="96"/> + <circ-port height="8" pin="480,440" width="8" x="156" y="116"/> + <circ-anchor facing="east" height="6" width="6" x="157" y="17"/> + </appear> <wire from="(220,250)" to="(220,320)"/> - <wire from="(330,210)" to="(380,210)"/> + <wire from="(230,420)" to="(480,420)"/> <wire from="(180,180)" to="(230,180)"/> - <wire from="(510,430)" to="(510,440)"/> <wire from="(260,220)" to="(260,230)"/> - <wire from="(540,370)" to="(540,440)"/> <wire from="(210,230)" to="(210,370)"/> - <wire from="(560,450)" to="(600,450)"/> - <wire from="(140,20)" to="(380,20)"/> <wire from="(350,100)" to="(350,180)"/> <wire from="(180,210)" to="(180,300)"/> <wire from="(270,360)" to="(310,360)"/> <wire from="(220,100)" to="(220,130)"/> - <wire from="(640,440)" to="(640,460)"/> <wire from="(290,70)" to="(320,70)"/> + <wire from="(200,380)" to="(420,380)"/> <wire from="(260,130)" to="(280,130)"/> - <wire from="(500,450)" to="(520,450)"/> <wire from="(160,30)" to="(180,30)"/> - <wire from="(460,380)" to="(470,380)"/> <wire from="(160,260)" to="(240,260)"/> <wire from="(380,300)" to="(390,300)"/> <wire from="(230,350)" to="(240,350)"/> <wire from="(220,130)" to="(220,250)"/> - <wire from="(380,140)" to="(380,210)"/> - <wire from="(200,320)" to="(200,390)"/> - <wire from="(140,430)" to="(140,440)"/> + <wire from="(200,320)" to="(200,380)"/> + <wire from="(230,350)" to="(230,420)"/> <wire from="(230,100)" to="(350,100)"/> - <wire from="(330,140)" to="(380,140)"/> <wire from="(180,190)" to="(230,190)"/> <wire from="(300,150)" to="(300,160)"/> - <wire from="(500,430)" to="(500,450)"/> <wire from="(160,30)" to="(160,180)"/> <wire from="(180,70)" to="(180,90)"/> <wire from="(230,80)" to="(230,100)"/> <wire from="(250,220)" to="(250,240)"/> <wire from="(140,20)" to="(140,110)"/> - <wire from="(230,350)" to="(230,440)"/> <wire from="(190,170)" to="(230,170)"/> <wire from="(200,300)" to="(240,300)"/> <wire from="(180,30)" to="(180,60)"/> <wire from="(160,210)" to="(160,240)"/> - <wire from="(130,580)" to="(230,580)"/> <wire from="(220,50)" to="(250,50)"/> - <wire from="(530,410)" to="(550,410)"/> - <wire from="(140,200)" to="(140,430)"/> <wire from="(170,210)" to="(170,310)"/> - <wire from="(200,390)" to="(420,390)"/> + <wire from="(400,30)" to="(400,190)"/> <wire from="(260,140)" to="(280,140)"/> - <wire from="(130,620)" to="(130,660)"/> - <wire from="(390,190)" to="(390,300)"/> + <wire from="(410,250)" to="(410,360)"/> <wire from="(190,120)" to="(190,170)"/> + <wire from="(140,200)" to="(140,440)"/> <wire from="(160,330)" to="(170,330)"/> - <wire from="(230,640)" to="(240,640)"/> <wire from="(180,60)" to="(250,60)"/> <wire from="(160,240)" to="(230,240)"/> - <wire from="(380,20)" to="(380,140)"/> - <wire from="(130,590)" to="(130,600)"/> <wire from="(250,150)" to="(250,160)"/> <wire from="(290,110)" to="(340,110)"/> <wire from="(180,200)" to="(230,200)"/> <wire from="(210,230)" to="(260,230)"/> <wire from="(290,110)" to="(290,120)"/> <wire from="(290,150)" to="(290,160)"/> - <wire from="(570,430)" to="(570,460)"/> <wire from="(200,300)" to="(200,320)"/> <wire from="(140,110)" to="(140,200)"/> - <wire from="(500,370)" to="(540,370)"/> <wire from="(210,370)" to="(240,370)"/> - <wire from="(310,360)" to="(470,360)"/> + <wire from="(430,240)" to="(430,340)"/> <wire from="(250,240)" to="(340,240)"/> - <wire from="(390,30)" to="(390,190)"/> <wire from="(200,110)" to="(290,110)"/> + <wire from="(140,20)" to="(360,20)"/> + <wire from="(330,210)" to="(360,210)"/> <wire from="(330,180)" to="(350,180)"/> <wire from="(240,220)" to="(240,260)"/> - <wire from="(220,410)" to="(500,410)"/> - <wire from="(180,30)" to="(390,30)"/> <wire from="(230,240)" to="(230,350)"/> + <wire from="(140,440)" to="(480,440)"/> <wire from="(230,240)" to="(250,240)"/> <wire from="(230,80)" to="(250,80)"/> - <wire from="(220,630)" to="(240,630)"/> - <wire from="(570,460)" to="(640,460)"/> + <wire from="(420,240)" to="(430,240)"/> <wire from="(140,200)" to="(150,200)"/> + <wire from="(390,250)" to="(390,300)"/> <wire from="(180,70)" to="(250,70)"/> + <wire from="(220,400)" to="(420,400)"/> <wire from="(180,120)" to="(180,180)"/> - <wire from="(330,190)" to="(390,190)"/> <wire from="(270,90)" to="(270,160)"/> + <wire from="(360,140)" to="(360,210)"/> <wire from="(160,260)" to="(160,330)"/> <wire from="(340,110)" to="(340,240)"/> + <wire from="(430,340)" to="(480,340)"/> <wire from="(240,150)" to="(240,160)"/> <wire from="(180,210)" to="(230,210)"/> <wire from="(220,250)" to="(270,250)"/> <wire from="(320,150)" to="(320,160)"/> - <wire from="(260,650)" to="(260,660)"/> <wire from="(310,340)" to="(310,360)"/> - <wire from="(130,560)" to="(130,580)"/> - <wire from="(220,320)" to="(220,410)"/> + <wire from="(220,320)" to="(220,400)"/> + <wire from="(400,190)" to="(400,220)"/> <wire from="(270,220)" to="(270,250)"/> - <wire from="(140,430)" to="(500,430)"/> - <wire from="(520,430)" to="(520,450)"/> - <wire from="(560,430)" to="(560,450)"/> <wire from="(140,110)" to="(170,110)"/> - <wire from="(510,440)" to="(540,440)"/> + <wire from="(180,30)" to="(400,30)"/> + <wire from="(330,140)" to="(360,140)"/> <wire from="(220,320)" to="(240,320)"/> <wire from="(200,100)" to="(220,100)"/> + <wire from="(410,360)" to="(420,360)"/> <wire from="(220,50)" to="(220,100)"/> <wire from="(220,130)" to="(230,130)"/> <wire from="(320,70)" to="(320,120)"/> - <wire from="(130,660)" to="(260,660)"/> - <wire from="(230,580)" to="(230,640)"/> + <wire from="(360,20)" to="(360,140)"/> + <wire from="(330,190)" to="(400,190)"/> <comp loc="(260,130)" name="ALU"/> - <comp lib="3" loc="(460,380)" name="Comparator"/> - <comp lib="0" loc="(130,590)" name="Splitter"> - <a name="facing" val="south"/> - <a name="fanout" val="8"/> - <a name="incoming" val="8"/> + <comp lib="0" loc="(480,340)" name="Pin"> + <a name="facing" val="west"/> + <a name="tristate" val="false"/> + <a name="pull" val="down"/> + <a name="label" val="IN ENABLE"/> + <a name="labelloc" val="east"/> </comp> - <comp loc="(230,170)" name="ISD"/> - <comp lib="0" loc="(220,630)" name="Splitter"> - <a name="facing" val="north"/> - <a name="fanout" val="8"/> - <a name="incoming" val="7"/> + <comp lib="0" loc="(420,380)" name="Pin"> + <a name="facing" val="west"/> + <a name="output" val="true"/> + <a name="width" val="8"/> + <a name="tristate" val="false"/> + <a name="pull" val="down"/> + <a name="label" val="ADDR"/> + <a name="labelloc" val="east"/> </comp> + <comp loc="(230,170)" name="ISD"/> <comp lib="0" loc="(290,340)" name="Constant"> <a name="facing" val="north"/> </comp> <comp loc="(190,90)" name="STK"/> <comp loc="(280,150)" name="GPR"/> + <comp lib="0" loc="(480,440)" name="Pin"> + <a name="facing" val="west"/> + <a name="tristate" val="false"/> + <a name="pull" val="down"/> + <a name="label" val="RST"/> + <a name="labelloc" val="east"/> + </comp> <comp lib="1" loc="(270,360)" name="AND Gate"> <a name="size" val="30"/> <a name="inputs" val="2"/> </comp> - <comp lib="5" loc="(600,440)" name="Hex Digit Display"/> - <comp lib="4" loc="(530,410)" name="Register"/> <comp lib="2" loc="(290,70)" name="Multiplexer"> <a name="select" val="2"/> <a name="width" val="8"/> <a name="enable" val="false"/> </comp> - <comp lib="0" loc="(140,440)" name="Pin"> - <a name="facing" val="north"/> + <comp lib="0" loc="(480,420)" name="Pin"> + <a name="facing" val="west"/> <a name="tristate" val="false"/> + <a name="pull" val="down"/> + <a name="label" val="CLK"/> + <a name="labelloc" val="east"/> </comp> - <comp lib="0" loc="(550,410)" name="Splitter"> - <a name="facing" val="south"/> - <a name="incoming" val="8"/> - <a name="bit1" val="0"/> - <a name="bit2" val="0"/> - <a name="bit3" val="0"/> - <a name="bit4" val="1"/> - <a name="bit5" val="1"/> - <a name="bit6" val="1"/> - <a name="bit7" val="1"/> - </comp> - <comp lib="6" loc="(618,320)" name="Text"> - <a name="text" val="In this case, I have only one Memory Mapped output port mapped @ 0xFF."/> - </comp> - <comp lib="0" loc="(230,440)" name="Clock"> + <comp lib="2" loc="(400,220)" name="Multiplexer"> <a name="facing" val="north"/> + <a name="selloc" val="tr"/> + <a name="width" val="8"/> + <a name="enable" val="false"/> </comp> <comp loc="(160,210)" name="PC"/> - <comp lib="5" loc="(640,440)" name="Hex Digit Display"/> - <comp lib="6" loc="(586,480)" name="Text"> - <a name="text" val="For printing hex values from I/O"/> + <comp lib="0" loc="(420,400)" name="Pin"> + <a name="facing" val="west"/> + <a name="output" val="true"/> + <a name="width" val="8"/> + <a name="tristate" val="false"/> + <a name="pull" val="down"/> + <a name="label" val="OUT"/> + <a name="labelloc" val="east"/> </comp> - <comp lib="5" loc="(240,640)" name="TTY"/> - <comp lib="0" loc="(420,370)" name="Constant"> + <comp lib="0" loc="(420,360)" name="Pin"> + <a name="facing" val="west"/> <a name="width" val="8"/> - <a name="value" val="0xff"/> + <a name="tristate" val="false"/> + <a name="pull" val="down"/> + <a name="label" val="IN"/> + <a name="labelloc" val="east"/> </comp> <comp lib="4" loc="(380,300)" name="RAM"> <a name="bus" val="separate"/> </comp> - <comp lib="1" loc="(500,370)" name="AND Gate"> - <a name="size" val="30"/> - <a name="inputs" val="2"/> - </comp> <comp lib="2" loc="(200,320)" name="Multiplexer"> <a name="selloc" val="tr"/> <a name="width" val="8"/> @@ -6160,4 +6166,71 @@ This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). <a name="enable" val="false"/> </comp> </circuit> + <circuit name="7SegDisplay"> + <a name="circuit" val="7SegDisplay"/> + <a name="clabel" val=""/> + <a name="clabelup" val="east"/> + <a name="clabelfont" val="SansSerif plain 12"/> + <wire from="(180,60)" to="(230,60)"/> + <wire from="(180,160)" to="(230,160)"/> + <wire from="(180,80)" to="(230,80)"/> + <wire from="(460,60)" to="(460,70)"/> + <wire from="(420,60)" to="(420,70)"/> + <wire from="(340,90)" to="(340,100)"/> + <wire from="(180,120)" to="(350,120)"/> + <wire from="(260,140)" to="(370,140)"/> + <wire from="(370,110)" to="(370,140)"/> + <wire from="(350,90)" to="(350,120)"/> + <wire from="(180,100)" to="(280,100)"/> + <wire from="(430,70)" to="(460,70)"/> + <wire from="(230,160)" to="(230,260)"/> + <wire from="(320,90)" to="(340,90)"/> + <wire from="(340,100)" to="(360,100)"/> + <wire from="(390,90)" to="(410,90)"/> + <wire from="(230,160)" to="(380,160)"/> + <wire from="(180,140)" to="(260,140)"/> + <wire from="(270,80)" to="(280,80)"/> + <wire from="(350,90)" to="(360,90)"/> + <wire from="(380,110)" to="(380,160)"/> + <wire from="(260,140)" to="(260,260)"/> + <comp lib="0" loc="(410,90)" name="Splitter"> + <a name="facing" val="north"/> + <a name="incoming" val="8"/> + <a name="appear" val="right"/> + <a name="bit1" val="0"/> + <a name="bit2" val="0"/> + <a name="bit3" val="0"/> + <a name="bit4" val="1"/> + <a name="bit5" val="1"/> + <a name="bit6" val="1"/> + <a name="bit7" val="1"/> + </comp> + <comp lib="5" loc="(460,60)" name="Hex Digit Display"/> + <comp loc="(180,60)" name="MCU"/> + <comp lib="0" loc="(230,260)" name="Pin"> + <a name="facing" val="north"/> + <a name="tristate" val="false"/> + </comp> + <comp lib="4" loc="(390,90)" name="Register"/> + <comp lib="0" loc="(230,60)" name="Pin"> + <a name="facing" val="west"/> + <a name="tristate" val="false"/> + </comp> + <comp lib="0" loc="(260,260)" name="Clock"> + <a name="facing" val="north"/> + </comp> + <comp lib="0" loc="(270,80)" name="Constant"> + <a name="width" val="8"/> + <a name="value" val="0xff"/> + </comp> + <comp lib="3" loc="(320,90)" name="Comparator"> + <a name="mode" val="unsigned"/> + </comp> + <comp lib="0" loc="(230,80)" name="Constant"> + <a name="facing" val="west"/> + <a name="width" val="8"/> + <a name="value" val="0xff"/> + </comp> + <comp lib="5" loc="(420,60)" name="Hex Digit Display"/> + </circuit> </project> diff --git a/INSTRUCTION_SET b/INSTRUCTION_SET @@ -1,16 +1,39 @@ -TISC -00000000 -C B A 00 - OR - C = A || B -C B A 01 - NAND- C = A nand B -C B A 10 - ADD - C = A + B -C B 0010 - CIN - C = ++B -00B 11 - LLI - load lower immediate to reg 1 (resets reg.) -01B 11 - LUI - load upper immediate to reg 1 (OR's lower 4 bits) -10000011 - JMP - on next line use as adress if flag is true -10010011 - PUS - Push reg 1 to stack -10100011 - POP - Pop stack to reg 1 -10110011 - PCR - Get current line and save to register 1 -10B 0111 - LB - Load word from mem pointer to reg B -10B 1011 - SB - Store reg B to mem pointer -10B 1111 - SP - set pointer B -11B A 11 - CMP - compare if A>B +TISCv1.0 (c) Paul Longtine <paul@nanner.co> + +T I S C + i n e o + n s t m + y t p + r u + u t + c e + t r + i + o + n +-----------------------------------------------------------------------< +RAW - memonic - description +-----------------------------------------------------------------------< +00000000 - NOP ----- do nothing +C B A 00 - OR ----- C = A || B +C B A 01 - NAND----- C = A nand B +C B A 10 - ADD ----- C = A + B +C B 0010 - CIN ----- C = ++B +00<lo>11 - LLI ----- load lower immediate to GRA +01<hi>11 - LUI ----- load upper immediate to GRA +10000011 - JMP ----- jmp to address in next program word if flag is true +10010011 - PUS ----- Push GRA to stack +10100011 - POP ----- Pop stack to reg GRA +10110011 - PCR ----- Get current line and save to register GRA +10B 0111 - LB ----- Load word from mem pointer to ARGB GPR +10B 1011 - SB ----- Store contents of ARGB GPR to mem pointer +10B 1111 - SP ----- set pointer ARGB +11B A 11 - CMP ----- sets flag if contents of ARGA>ARGB +-----------------------------------------------------------------------< +C = Arguement C / ARGC +B = Arguement B / ARGB +A = Arguement A / ARGA + +GRA = General Purpose Register A +GRB = General Purpose Register B +GRC = General Purpose Register C+ \ No newline at end of file diff --git a/tisc.c b/tisc.c @@ -10,6 +10,8 @@ #define MAX_INSTYPES 4 #define MAX_PGR_SIZE 0xFF +#define GR_N 0x0 +#define GR_N_STRING "NUL" #define GR_A 0x1 #define GR_A_STRING "GRA" #define GR_B 0x2 @@ -132,6 +134,10 @@ uint8_t getRegisterEnumeration(char* string) if ((string != NULL) && (strcmp(string, GR_C_STRING) == 0)) { return GR_C; + } else + if ((strin != NULL) && (strcmp(string, GR_N_STRING) == 0)) + { + return GR_N; } return 0xFF;