-
Notifications
You must be signed in to change notification settings - Fork 1
optixx/mycpu
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
YourFirstASM This project was constructed using Flex and Bison. These utilities are used to make various compilers such as gnu-c, gnu-asm, etc., based on an input grammer similar to BNF language grammers. The files of most interest in this project are the files scanner.l (the lexer file) and parser.y (the parser grammer). These files are the input to Flex and Bison, respectively. Here are a short description of each source file: scanner.l This file contains a definition for Flex. Flex compiles this file into a regular c file (scanner.c) that reads input from a file and outputs tokens to the parser. In simple terms, it breaks the input file into the various identifiers, keywords, numbers, strings, and punctuation. parser.y This file contains a BNF-like grammer definition. Bison compiles this file into a regular c file (parser.c) that takes tokens from the scanner and with the grammer syntax parses the input file. The grammer definition is embedded with actions that generate the assembler output for the given input file. ** For more information on input scanners and parsers see *** Flex and Bison, or Lex and Yacc. yfasm.h The yfasm.h contain any definitions that are shared between the lexer and the parser source files. yfsys.h Contains information about the CPU design such as bit widths of the instruction word and mnemonic op-codes. scanner.c These files are generated by Flex and Bison and the & parser.c input files scanner.l and parser.y. Thus these files are not included in the distribution and are also deleted by "make clean". main.c The main program. Very simple in design it calls the parser on each input file. It then takes the assembler output (raw instruction memory) and formats it to stdout. This is the initial construction of an assembler for the Your First CPU soft processor tutorial. To simplify the code many features were not included such as a fancy command line parser with switches. Currently, the yfasm program assembles all source files on the command line and outputs a single hex integer per line for each instruction. This output file format is suitable for ModelSim and many others that load memory contents via the $readmemh() verilog directive. To compile the assembler, use: $ make To compile the test asm file with the assember, use: $ ./yfasm test.asm > test.rom The Makefile also contains some other commands, such as: make clean Cleans intermediate object files. make test Compiles the assembler and runs it against a test asm input file (test.asm). (note!) Do not redirect this to a rom file, or the assembler build info will be redirected as well! make depend refreshes the dependancies between the source files. Use this if you adjust the include files or add source files to this project. make rebuild perform a "make clean" and "make".
About
Simple cpu in Verilog + Assembler in c and python
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published