Verilog에서 보다 깔끔하면서 configurable 한 코드를 만들기 위해 generate 문을 활용할 수 있다.

일반적으로 자주 사용하는 문법은 아니지만, 긴 코드를 작성할 때 유리하다.


generate 문은 일반적인 verilog 문법과는 다르게, pre-compile 된다고 이해하면 쉽다.

(C언어에서의 전처리기 명령어(#define 등)와 비슷하다.)


generate 문에는 아래와 같이 2가지 종류가 있다.

1. generate loop

일반적으로 verilog에서는 for 문을 사용하지 않는다. Verilog에서 사용하는 for 문은 사실 generate 문의 일부이다.

loop index는 genvar로 선언하여야 하며, generate loop 내에서 선언된 wire 등은 loop iteration 간의 충돌이 일어나지 않는다.(local 변수로 이해하면 된다.)

genvar idx;

generate

for(idx = 0; idx < 3; idx = idx + 1) begin : gen_inst

wire w1, w2;

assign w1 = in1[idx] & in2[idx];

assign w2 = in1[idx] | in2[idx];

assign out[idx] = w1 & w2;

end

endgenerate

위의 코드는 아래와 같다.

wire gen_inst[0].w1, gen_inst[0].w2;

assign gen_inst[0].w1 = in1[0] & in2[0];

assign gen_inst[0].w2 = in1[0] | in2[0];

assign out[0] = gen_inst[0].w1 & gen_inst[0].w2;

wire gen_inst[1].w1, gen_inst[1].w2;

assign gen_inst[1].w1 = in1[1] & in2[1];

assign gen_inst[1].w2 = in1[1] | in2[1];

assign out[1] = gen_inst[1].w1 & gen_inst[1].w2;

wire gen_inst[2].w1, gen_inst[2].w2;

assign gen_inst[2].w1 = in1[2] & in2[2];

assign gen_inst[2].w2 = in1[2] | in2[2];

assign out[2] = gen_inst[2].w1 & gen_inst[2].w2;

2. if-generate / case-generate

if-generate와 case-generate는 코드에는 등장하지만, 조건에 따라서 실제 synthesis 되지 않는 코드를 말한다.

간단히 이해하기로는, parameter 등 constant 한 값에 의한 if / case 문에서 해당될 수 없는 구문은 애초에 없는 코드로 생각하면 된다.


주의 사항

 - generate 문은 generate 와 endgenerate 사이로 구성할 수 있으나 사실 이는 필수는 아니다.

 - generate 문은 named / unamed 둘 다 가능하나, named로 사용하는 편이 좋다.


참조: http://www.verilogpro.com/verilog-generate-configurable-rtl/

'Programming > Verilog' 카테고리의 다른 글

AXI FIFO  (0) 2020.02.13
AXI Register Slice  (0) 2020.02.12
Xilinx bootgen  (0) 2017.06.21
Xilinx SDK disable cache  (0) 2017.06.12
Xilinx Vivado IP import  (0) 2017.05.31

Linux 에서 여러 파일 간의 코드 연결을 보고자 할 때, Ctags를 활용 할 수 있다.


설치

$ sudo apt-get install ctags


태그 생성

$ ctags -R


명령어(Vim 사용 중)

 - 커서 + Ctrl + ] : 커서 위치의 tag로 이동(push to stack)

 - :ts : tag stack 확인

 - Ctrl + t : Pop stack

'Programming > Linux' 카테고리의 다른 글

Xshell + Xming  (0) 2018.09.10
Memtester  (0) 2018.07.15
scp  (0) 2018.05.29
Systemd Service  (0) 2018.05.04
Linux tar, gz, bz2  (0) 2018.04.25

Ubuntu에서 Remote Desktop Client를 써 봤을 때, 매우 만족했었다.

해당 Remote Desktop Client는 Remmina인데,

Raspbian에서도 설치가 가능하다.


설치는

$ sudo apt-get install remmina


사용법은

$ remmina

윈도우 접속 하고자 하는 경우: RDP 선택 후, IP 입력하면 연결 할 수 있다.


라즈베리 파이로 돌리기에는 다소 버거울 수 있지만, 

그래도 없는 것 보다는 낫지 않을까...?하는 마음으로 켜봤는데

예상보다 훨~~씬 빠르다!!! 오히려 라즈베리파이 데스크톱 보다 빠른 느낌...?

'Programming > RaspberryPi' 카테고리의 다른 글

Rasbian qbittorrent-nox installation  (0) 2019.11.19
SD card image backup  (0) 2018.10.12
SDcard Partition Resize  (0) 2018.08.21
Raspbian Korean(Hangul) Install  (0) 2018.05.18
Raspbian Install  (0) 2018.05.16

Linux 상에서 다른 서버의 파일을 복사해 오고자 하는 경우

scp 명령어를 활용할 수 있다.


scp 명령어는 cp와 문법이 비슷하다.

$ scp <user_id>@<ip_addess_of_source>:/<file> <user_id>@<ip_address_of_dest>:/<file_name>

scp 명령어를 사용하는 서버로(부터) 옮기고자 하는 경우에는 <user_id>@<ip_address>:를 생략 할 수 있다.


scp 명령어를 사용할 때 password를 포함하게 하는 방법

$ sshpass -p '<PASSWORD>' scp <user_id>@<ip_addess_of_source>:/<file> <user_id>@<ip_address_of_dest>:/<file_name>

※ 이렇게 사용하면 PASSWORD가 드러날 수 있으니 보안에 취약하다는 점을 유념하자.

'Programming > Linux' 카테고리의 다른 글

Memtester  (0) 2018.07.15
Ctags  (0) 2018.07.03
Systemd Service  (0) 2018.05.04
Linux tar, gz, bz2  (0) 2018.04.25
Linux HDD mount  (0) 2018.04.06

Kernel Module Programming

Module 기본 구조

#include <linux/module.h>

#include <linux/kernel.h>


int init_module(void)

{

printk("<1>Hello world\n");

return 0;

}


void cleanup_module(void)

{

printk(KERN_ALERT "Bye World\n");

}

※ init_module()은 모듈 추가(insmod) 시, cleanup_module()은 모듈 삭제(rmmod) 시 호출 됨


아래와 같이 헤더로 linux/init.h 를 포함하고, module_init/module_exit 함수를 통해 init_module()/cleanup_module() 함수의 이름을 자유롭게 설정할 수 있다.

#include <linux/module.h>

#include <linux/kernel.h>

#inlcude <linux/init.h>


int my_init(void)

{

printk(KERN_ALERT"Hello World\n");

return 0;

}


void my_exit(void)

{

printk(KERN_ALERT"Bye World\n");

}


module_init(my_init);

module_exit(my_exit);


Device 를 시스템에서 사용하기 위해서는 우선 디바이스 노드를 만들어야 한다.

$ sudo mknod /dev/<device_name> <major_num> <minor_num>

$ sudo chmod 666 /dev<device_name>




참조: https://www.joinc.co.kr/w/Site/Embedded/Documents/LinuxKernelModuleProg 

'Programming > Linux Kernel' 카테고리의 다른 글

cross kernel debugging  (0) 2020.06.19
Linux kernel module compile from linux source  (0) 2019.01.17
Kernel Version Check  (0) 2018.05.23
Kernel 프로그래밍 - printk  (0) 2017.06.20

Linux 시스템 상에서 kernel의 version을 확인하기 위한 방법

$ cat /proc/version


참조: https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EC%BB%A4%EB%84%90_%EB%B2%84%EC%A0%84_%ED%99%95%EC%9D%B8

'Programming > Linux Kernel' 카테고리의 다른 글

cross kernel debugging  (0) 2020.06.19
Linux kernel module compile from linux source  (0) 2019.01.17
Kernel module programming  (0) 2018.05.23
Kernel 프로그래밍 - printk  (0) 2017.06.20

Bash script에서 for문은 아래와 같은 형태를 가진다.

for <variable> in <list>

do

statements

done


C언어에서와 같이 i++을 진행하면서 하고자 하는 경우,

for i in `seq 1 10`;

do

statements

done

※seq 1 3 == 1,2,3

'Programming > Bash Script' 카테고리의 다른 글

Bash if statement with regex  (0) 2021.09.06
Bash script argument parsing with getopts  (0) 2020.01.23
Bash Script case statement  (0) 2018.02.06
Bash Script Variable Split by Space  (0) 2018.02.04
Bash Script Echo  (0) 2018.02.04

Raspbian 을 처음 설치하면, 한글이 설치 되지 않아, Naver 에 접속해도 깨져보이고, 키보드의 한영키 를눌러도, 한글이 입력되지 않는다.

한글 폰트  및 한글 입력기가 설치 되어  있지 않아서 그렇다.


한글 폰트를 설치하여, 깨지지 않게 보기 위한 방법 

$ sudo apt-get install fonts-nanum


한글 입력을 하기 위한 방법

$ sudo apt-get install ibus-hangul

$ ibus-setup

ibus-setup 을 실행하면,  뜨는 창에서 Input Method 탭에서 Korean을 찾아 Add 하면된다.

ibus-hangul 은  일부 환경(티스토리)에서 띄어쓰기가 제멋대로 되는 문제가있다.ㅠ

그나마, iBusHangul Setup 에서 Commit in word unit  옵션을 활성화 하면 쓸 수 있는 정도가 되긴하는데,  완벽하진않다.


그래서 대안으로 설치한 uim!

문제없이 동작 잘 된다. 설치 방법

$ sudo apt-get install uim uim-byeoru

uim은 키보드입력기 일테고, byeoru 는 뭐지? 했는데, 한글입력을 위한 패키지 이름인가보다.

한영 전환은 shift+space

'Programming > RaspberryPi' 카테고리의 다른 글

Rasbian qbittorrent-nox installation  (0) 2019.11.19
SD card image backup  (0) 2018.10.12
SDcard Partition Resize  (0) 2018.08.21
RaspberryPi Remote Desktop Client  (0) 2018.06.01
Raspbian Install  (0) 2018.05.16

Raspbian installation on Raspberry Pi 3


Raspberry Pi 3 model B는 프로세서로 Broadcom BCM2837를 포함하고 있는데, 이는 ARM Cortex A-53 quad core를 포함한다.

Raspbian은 Raspberry Pi 를 위한 Debian based OS이다.

RaspberryPi 에는 다른 OS 보다 Raspbian 을 사용하는 것이 편리할 수 있다.


Raspbian 은 Rasberry Pi 사이트로 부터 다운 받을 수 있다.

2018년 5월 현재 Stable 버전인 RASPBIAN STRETCH WITH DESKTOP 을 다운 받으면 된다.

stretch는 Debian의 code name 이다.

zip 파일을 다운 받아 압축을 풀면(반디집 등으로 풀면 됨) .img 파일이 나온다.


다운받은 image 를 USB bunner중 하나인 Etcher 를 사용하여 USB 디스크를 만들면 된다.

Etcher는 https://etcher.io 에서 다운로드

Select image로 위에서 압축 풀어 나온 .img 파일을 선택하고

USB 장치는 자동으로 선택되는데, 잘 선택 되었는지 확인 

Flash!를 하면 된다. 쉽다.


참조: https://www.raspberrypi.org/documentation/installation/installing-images/README.md

'Programming > RaspberryPi' 카테고리의 다른 글

Rasbian qbittorrent-nox installation  (0) 2019.11.19
SD card image backup  (0) 2018.10.12
SDcard Partition Resize  (0) 2018.08.21
RaspberryPi Remote Desktop Client  (0) 2018.06.01
Raspbian Korean(Hangul) Install  (0) 2018.05.18

Linux에서 백그라운드로 자동으로 실행하게끔 service를 등록할 수 있다.

현재 등록된 service 목록은 /etc/systemd/system 경로에 *.service 파일을 보면 확인 할 수 있다.


systemd는 Linux의 init system 중 하나로,

init system을 사용하는 가장 기본적인 이유는 Linux system 이 부팅 된 다음 User영역의 Component를 initialize 하기 위함이다.

또한 백그라운드에서 동작하는 daemon이나 서비스를 관리하기 위함이다.

간단하게, /etc/init.d 경로에 있는 script 등은 System V init, /etc/systemd/system 경로에 있는 *.service는 systemd 라고 생각하면 된다.


가장 간단하게 systemd를 추가하는 방법은 아래와 같은 파일을 /etc/systemd/system 경로에 추가 하면 된다.

파일 이름은 <service_name>.service

[Unit]

Description=<Description of your own service>

After=network.target


[Service]

ExecStart=<File would be executed with this service>


[Install]

WantedBy=multi-user.target

Description: 해당 service에 대한 설명으로, systemctl status로 확인 할 때 가장 첫 줄에 표현된다.

ExecStart: 실행할 파일의 절대경로

※위의 ExecStart 로 표기된 파일은 ./<file> & 와 비슷한 방식으로 구동되기 때문에, 실행되는 파일의 첫 줄에 해당 파일을 실행할 shell을 나타내는 shebang(#!)을 포함해줘야 한다.


<service_name.service 파일을 추가 한 후에는,

$ sudo systemctl daemon-reload

를 통해 새로운 모듈을 load 하고,

시작, 정지, 상태 확인은 아래와 같은 명령어로 할 수 있다.

$ sudo systemctl start <service_name>

$ sudo systemctl stop <service_name>

$ sudo systemctl restart <service_name>

$ sudo systemctl status <service_name>

부팅 시 자동으로 실행되게 하기 위해서는 아래와 같이 enable 하면 된다.

$ sudo systemctl enable <service_name>

$ sudo systemctl disable <service_name>


참조: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units



'Programming > Linux' 카테고리의 다른 글

Ctags  (0) 2018.07.03
scp  (0) 2018.05.29
Linux tar, gz, bz2  (0) 2018.04.25
Linux HDD mount  (0) 2018.04.06
HandBrakeCLI  (0) 2018.04.06

+ Recent posts