-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,000 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
./**/test_strip.csv | ||
./**/__pycache__ | ||
unit_tests.py | ||
tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Instrucciones: | ||
|
||
En el diseño de las instrucciones se ha intentado mantener | ||
libre los opcodes disponibles en la medida de lo posible para | ||
posibilitar la introducción de nuevas instrucciónes en el futuro | ||
haciendo los opcodes lo más largos posibles. | ||
|
||
D = Dirección | ||
I = Inmediato | ||
S = Bits de selección | ||
R = Registro de lectura | ||
W = Registro de escritura | ||
|
||
noop: 0000 00XX XXXX XXXX: No toma operandos | ||
|
||
jump: 0000 01DD DDDD DDDD: Salto a D | ||
|
||
jumpz: 0000 10DD DDDD DDDD: Salto a D si flag Zero = 1 | ||
|
||
nojumpz: 0000 11DD DDDD DDDD: Salto a D si flag Zero = 0 | ||
|
||
limm: 0001 IIII IIII WWWW: Cargar I en W | ||
|
||
jal: 0010 00DD DDDD DDDD: Salto a D guardando dir. retorno (PC + 1) | ||
|
||
ret: 0010 01XX XXXX XXXX: No toma operandos | ||
|
||
read: 0010 10SS XXXX WWWW: SS seleccionan el puerto de lectura | ||
|
||
write: 0010 11SS RRRR XXXX: SS seleccionan el puerto de escritura | ||
|
||
MOV: 1000 RRRR XXXX WWWW: Guarda R en W | ||
|
||
NEG: 1001 RRRR XXXX WWWW: Niega R y guarda en W | ||
|
||
ADD: 1010 RRRR RRRR WWWW: R1 + R2 -> W | ||
|
||
SUB: 1011 RRRR RRRR WWWW: R1 - R2 -> W | ||
|
||
AND: 1100 RRRR RRRR WWWW: R1 & R2 -> W | ||
|
||
OR: 1101 RRRR RRRR WWWW: R1 | R2 -> W | ||
|
||
SIGNA: 1110 RRRR XXXX WWWW: Cambia signo a R y guarda en W | ||
|
||
SIGNB: 1110 XXXX RRRR WWWW: Cambia signo a R y guarda en W | ||
|
||
|
||
E/S: | ||
La entrada salida se compone de un banco de cuatro registros para la | ||
salida en el que se escriben los datos y cuatro puertos de entrada. | ||
La salida se compone unicamente de varios multiplexores y wires. | ||
No se han implementado escritura de inmediatos para no gastar opcodes | ||
y por ser menos flexibles que la escritura desde registro. | ||
|
||
Timer: | ||
El timer esta diseñado para tener una presición de 1ms al conectarse | ||
a un relog de 24MHz. Es necesario pasarle un numero(8b) de ms que en | ||
el caso de esta cpu se envia por el puerto 0 y permite generar señales | ||
periódicas de entre 1ms y 250ms. | ||
|
||
Interrupciones: | ||
La cpu permite 4 interrupciones externas que selecciónan una dirección | ||
de memoria donde se deberá encontrar una subrutina que termine en una | ||
instrucción ret que devuelva la ejecución del programa a su cauce normal. | ||
Hasta que no implemente una pila para los JAL cualquier interrupción | ||
sobrescribirá cualquier información presente en el registro de retorno. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# This file is used to ignore files which are generated | ||
# ---------------------------------------------------------------------------- | ||
|
||
*~ | ||
*.autosave | ||
*.a | ||
*.core | ||
*.moc | ||
*.o | ||
*.obj | ||
*.orig | ||
*.rej | ||
*.so | ||
*.so.* | ||
*_pch.h.cpp | ||
*_resource.rc | ||
*.qm | ||
.#* | ||
*.*# | ||
core | ||
!core/ | ||
tags | ||
.DS_Store | ||
.directory | ||
*.debug | ||
Makefile* | ||
*.prl | ||
*.app | ||
moc_*.cpp | ||
ui_*.h | ||
qrc_*.cpp | ||
Thumbs.db | ||
*.res | ||
*.rc | ||
/.qmake.cache | ||
/.qmake.stash | ||
|
||
# qtcreator generated files | ||
*.pro.user* | ||
|
||
# xemacs temporary files | ||
*.flc | ||
|
||
# Vim temporary files | ||
.*.swp | ||
|
||
# Visual Studio generated files | ||
*.ib_pdb_index | ||
*.idb | ||
*.ilk | ||
*.pdb | ||
*.sln | ||
*.suo | ||
*.vcproj | ||
*vcproj.*.*.user | ||
*.ncb | ||
*.sdf | ||
*.opensdf | ||
*.vcxproj | ||
*vcxproj.* | ||
|
||
# MinGW generated files | ||
*.Debug | ||
*.Release | ||
|
||
# Python byte code | ||
*.pyc | ||
|
||
# Binaries | ||
# -------- | ||
*.dll | ||
*.exe | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
noop | ||
limm 0 R1 | ||
limm 1 R2 | ||
limm 10 R3 | ||
:for | ||
add R1 R2 R1 | ||
sub R3 R1 zero | ||
jnz for | ||
:end | ||
jump end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>qtSCC</class> | ||
<widget class="QWidget" name="qtSCC"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>800</width> | ||
<height>600</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>qtSCC</string> | ||
</property> | ||
<widget class="QWidget" name="verticalLayoutWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>10</x> | ||
<y>10</y> | ||
<width>781</width> | ||
<height>581</height> | ||
</rect> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
<item> | ||
<widget class="QLineEdit" name="inputEdit"> | ||
<property name="readOnly"> | ||
<bool>false</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="SeachButton"> | ||
<property name="text"> | ||
<string>Search</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="assembleButton"> | ||
<property name="text"> | ||
<string>Assemble</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QListWidget" name="fileList"/> | ||
</item> | ||
<item> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QTextEdit" name="textEdit"> | ||
<property name="readOnly"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
<item> | ||
<widget class="QLineEdit" name="lineEdit"/> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="pushButton"> | ||
<property name="text"> | ||
<string>Save</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# This Python file uses the following encoding: utf-8 | ||
import sys | ||
import tempfile | ||
|
||
from PyQt5.QtGui import * | ||
from PyQt5.QtWidgets import * | ||
from PyQt5.QtCore import * | ||
|
||
from qtSCC import Ui_qtSCC | ||
import os | ||
sys.path.append(os.path.abspath('../../SCC')) | ||
import SCCUtils | ||
|
||
class qtSCC(QMainWindow, Ui_qtSCC): | ||
def __init__(self, *args, **kwargs): | ||
super(qtSCC, self).__init__(*args, **kwargs) | ||
self.setupUi(self) | ||
self.virtual_file = tempfile.SpooledTemporaryFile(mode = "w+", encoding = "utf-8", dir = "/tmp/") | ||
self.binaryCode = [] | ||
self.translationQueue = [] | ||
|
||
self.SearchButton.clicked.connect(self.onSearchButtonClicked) | ||
self.assembleButton.clicked.connect(self.onAssembleButtonClicked) | ||
self.saveButton.clicked.connect(self.onSaveButtonClicked) | ||
self.fileList.itemClicked.connect(self.onFileListItemClicked) | ||
self.translateList.itemClicked.connect(self.onTranslateListItemClicked) | ||
|
||
self.show() | ||
|
||
def onSaveButtonClicked(self): | ||
pass | ||
# fileName = self.saveEdit.text() | ||
# SCCUtils.writeList2File(fileName, self.binaryCode) | ||
|
||
def onAssembleButtonClicked(self): | ||
for fileName in self.translationQueue: | ||
binaryCode = self.assembleFile(fileName) | ||
binFileName = fileName.split('.')[0]; | ||
binFileName = binFileName + ".bin" | ||
SCCUtils.writeList2File(binFileName, binaryCode) | ||
self.translationQueue = []; | ||
|
||
def onSearchButtonClicked(self): | ||
self.fileList.clear() | ||
path = self.inputEdit.text() | ||
path = QDir(path) | ||
print(path.dirName()) | ||
path.setFilter(QDir.Files) | ||
contentsList = path.entryList() | ||
for content in contentsList: | ||
basePath = self.inputEdit.text() | ||
filePath = os.path.join(basePath, content) | ||
self.fileList.addItem(content) | ||
|
||
def onFileListItemClicked(self, item): | ||
basePath = self.inputEdit.text() | ||
filePath = os.path.join(basePath, item.text()) | ||
self.translateList.addItem(item.text()) | ||
self.translationQueue.append(filePath) | ||
|
||
def onTranslateListItemClicked(self, item): | ||
self.translationQueue.remove(item.text()) | ||
self.translateList.takeItem(self.translateList.currentRow()) | ||
|
||
def assembleFile(self, fileName): | ||
with open(fileName, 'r') as inputFile: | ||
SCCUtils.strip_input(self.virtual_file, inputFile) | ||
SCCUtils.operateFile(self.virtual_file, SCCUtils.resolveDirections) | ||
binaryCode = SCCUtils.operateFile(self.virtual_file, SCCUtils.translate) | ||
return binaryCode | ||
|
||
if __name__ == "__main__": | ||
app = QApplication([]) | ||
window = qtSCC() | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"files": ["main.py","form.ui","qtSCC.py"] | ||
} |
Oops, something went wrong.