2018/03/29

Verilog Development Environment with Mac

To develop Verilog codes with a Mac, the following tools may be used:

Command line editor: Nano

Graphical UI Editor: TextWrangler (Available on App Store for Free)

Compiler: Icarus Verilog (Install with Homebrew with command: brew install icarus-verilog)

Waveform Viewer: GTKWave (Write $dumpfile command to output vcd file

References:

如何在Mac OS X上安裝Verilog環境 (Instructions to Icarus Verilog and GTKWave installation)
is there a good verilog editor for mac?

Verilog vs. VHDL (Study EECC)
Digital Logic Design - Truth Table and K-map (Study EECC)

2018/03/16

Digital Logic Design - Truth Table and K-map

To convert digital logic conditions in a truth table to a digital circuit, use the K-map.

truth table 真值表
Karnaugh map / K-map 卡諾圖
Boolean algebra / logic algebra 布林代數 / 邏輯代數

References

Karnaugh map (Wikipedia)
Truth table (Wikipedia)
Boolean algebra (Wikipedia)
HOW TO: Combinational logic: Truth Table → Karnaugh Map → Minimal Form → Gate Diagram (YouTube)

Verilog Development Environment with Mac (Study EECC)

2018/03/10

Matlab: Run Hello World files written in C/C++ with MEX command

To run C/C++ files from Matlab, use the MEX command.
Create the files in C or C++:

C (hello.c)

#include"mex.h"
#include<stdio.h>

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
    printf("Hello, World!\n");
}


C++ (helloCPP.cpp)

#include"mex.h"
#include <iostream>

using namespace std;

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
    cout << "Hello, World!\n";

}

The mexFunction in either of the C or C++ example above is similar to the main function in pure C or C++ programs. Type your main program here such as printf in C or cout in C++.

Execute the files with the MEX command in Matlab such as below:

C
mex hello.c
hello

C++
mex helloCPP.cpp
helloCPP

Results in the Matlab command window:


References

Matlab 教材:測試 MEX-file
C language with Mac: Hello World with Mac's Terminal
C++ with Mac: Hello World with Mac's Terminal