Code Monkey home page Code Monkey logo

designing-a-simple-processor's Introduction

How to use

  1. Compile the "CO224Assembler.c" according to the instructions given in the C
    file and generate the executable named "CO224Assembler" (on Linux). Make sure you keep the generated executable in the current directory. You need to do
    this only once as long as the Assembler code is kept unchanged.

    Command: gcc CO224Assembler.c -o CO224Assembler
    
  2. Run the Shell script "generate_memory_image.sh" while passing the assembly program (your program.s file) as the only argument. There is a sample program (sample_program.s) under "programs" sub-directory for your reference.

    Command: ./generate_memory_image.sh <assembly_file_name>
             (e.g. ./generate_memory_image.sh programs/sample_program.s)
    

    This script ultimately generates a file named "instr_mem.mem" which contains the machine code of your Assembly program formatted according to a standard file format (.mem) supported by Verilog to initialize a memory array.

  3. In your testbench of the CPU of Simple Processor, add a line to read the generated memory content file and initialize the memory array you have declared in the testbench for instruction memory.

    Verilog syntax to initialize a memory array using the generated .mem file:
        $readmemb("instr_mem.mem", instr_mem);
    

    A sample testbench that includes this syntax to read the .mem file is given to you (cpu_tb.v). You may use it for the simulation of your Simple Processor.

(Note: As you may have already realized, once you have setup the files for the simulation by following above steps 1-3, you will only need to do step 2 every-time you need to load a new program to the CPU - given that the Assembler program and the location of instr_mem.mem file remains unchanged)

  1. To compile and run the code type the following commands

    iverilog -o a.out tb.v reg_file.v or.v insmem.v inscache.v forward.v dcache.v data_memory.v cpu.v and.v alu.v add.v
    
    vvp a.out
    

  2. To monitor the gtk wave , type the following command

         gtkwave cpu_wavedata.vcd
    

designing-a-simple-processor's People

Contributors

wijesooriyahd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.