西电VHDL期末设计解析

上传人:最**** 文档编号:116684584 上传时间:2019-11-17 格式:DOC 页数:14 大小:1.15MB
返回 下载 相关 举报
西电VHDL期末设计解析_第1页
第1页 / 共14页
西电VHDL期末设计解析_第2页
第2页 / 共14页
西电VHDL期末设计解析_第3页
第3页 / 共14页
西电VHDL期末设计解析_第4页
第4页 / 共14页
西电VHDL期末设计解析_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《西电VHDL期末设计解析》由会员分享,可在线阅读,更多相关《西电VHDL期末设计解析(14页珍藏版)》请在金锄头文库上搜索。

1、VHDL数字系统设计与测试 题 目 图像LSB嵌入和检测 学 院 通信工程学院 学 号 姓 名 一 设计要求与功能、利用vhdl语言设计一个图像处理系统,可完成以下功能(1)嵌入功能:可将一幅256x256的彩色图像转为8位灰度图像,然后在该灰度图像的LSB比特面随机嵌入三个不同的二值序列;最后,将嵌入水印序列的灰度图像恢复为彩色图像。(2)检测功能:输入任意彩色图像,可从对应灰度图像的LSB平面检测上述三个序列(3)三个序列为序列1:01101序列2:10101序列3:11001(4)输入端口包括三个坐标值信号,分别作为三个序列嵌入的起始位置二 设计思路本设计采用自上而下的设计思路,根据设计

2、要求将整体分解为8个子模块:文件读入模块,LSB嵌入模块,随机数产生模块,序列检测模块,VGA显示模块,主控模块。文件读入读出模块可暂借MATLAB处理,随机数产生模块,重点LSB嵌入模块:对相应的像素点进行模2运算得到最低位和相应序列进行比较。逐层描述并进行功能仿真(基于QuartusII综合仿真平台),最终实现硬件实现(硬件实现有待后续完成)。三 原理图说明图1 总体设计方案端口Clk:时钟信号端口En:使能控制信号ROM模块:存储器,负责临时文件信息的存储 嵌入LSB模块:负责取出LSB矩阵,并嵌入随机序列,再还原为彩色矩阵存入ROM 端口XY:随机嵌入的序列起始坐标文件读入模块:负责将

3、指定的图片转为数字矩阵,由于技术原因本文暂用matlab中的imread函数代替该功能。 检测模块: 负责利用状态机查找灰度LSB平面矩阵中是否嵌入有序列, 01101, 10101,11001,对应abc输出端口为1(有)或者0(无) 端口a,b,c:检测出序列01101-a为高反之为0 检测出序列10101-b为高反之为0 检测出序列11001-c为高反之为0不同序列的状态图如下:图2 01101状态机转换图图3 101010状态机转换图图4 110010状态机转换图 VGA显示模块: 负责还原前后的图像显示 VGA输出端口:r,g,b : out STD_LOGIC; -颜色信号 hs,

4、vs : out STD_LOGIC; -行同步、场同步信 号 随机数产生模块: 产生随机数列作为检测模块的输出数据四 子模块说明1)文件读入模块:利用Matlab工具imread函数将256*256彩色图片转为txt格式色值矩阵,存入rom中。2)LSB嵌入模块:entity Insert is port(clk:in std_logic; -时钟信号 en:in std_logic; -使能信号,控制嵌入进程的开始与结束 X1,Y1,X2,Y2, X3, Y3 : in integer range 1 to 256); -随机嵌入序列的三组起始位置(X1,y1),(X2,Y2), (X3,

5、Y3) end entity;architecture behavior of Insert is signal IN_data, OUT_data:matrix;file Infile:TEXT IS IN D:qianru.txt; -MATLAB转为灰度图像的矩阵的文本文件1file Outfile:TEXT IS OUT D:shuchu.txt;-嵌入之后的灰度图像的矩阵的文本文件2signal Pin:std_logic:=0;signal Pout:std_logic:=0;beginp1:process(clk) -将文件1读入variable line_in:LINE;var

6、iable int_v:integer:=0;beginif(clkevent and clk=1) then - 读入过程 if (en=0) thenfor i in 0 to row-1 loopreadline(Infile,line_in);for j in 0 to col-1 loopread(line_in,int_v);IN_data (i,j)=int_v;end loop;end loop;Pin=1 after 10ns; end if;end if;end process p1;p2: PROCESS(Pin) -image data processing -嵌入过程

7、variable i1:integer:=S1;variable j1:integer:=T1;variable i2:integer:=S2;variable j2:integer:=T2;variable i3:integer:=S3;variable j3:integer:=T3; -(S1, T1),( S2, T2),( S3, T3)分别为三个序列嵌入的起始坐标BEGINif (Pinevent and Pin=1) then -上升沿触发 IN_data(i1-1,j1-1)=IN_data(i1-1,j1-1)-(IN_data(i1-1,j1-1)mod 2)+0)mod 2

8、; -取LSB矩阵 if (j1=256) then i1:=i1+1;j1:=1; else j1:=j1+1; end if; IN_data(i1-1,j1-1)=IN_data(i1-1,j1-1)+(IN_data(i1-1,j1-1)mod 2)+1)mod 2; if (j1=256) then i1:=i1+1;j1:=1; else j1:=j1+1; end if; IN_data(i1-1,j1-1)=IN_data(i1-1,j1-1)+(IN_data(i1-1,j1-1)mod 2)+1)mod 2; if (j1=256) then i1:=i1+1;j1:=1;

9、 else j1:=j1+1; end if; IN_data(i1-1,j1-1)=IN_data(i1-1,j1-1)-(IN_data(i1-1,j1-1)mod 2)+0)mod 2; if (j1=256) then i1:=i1+1;j1:=1; else j1:=j1+1; end if; IN_data(i1-1,j1-1)=IN_data(i1-1,j1-1)+(IN_data(i1-1,j1-1)mod 2)+1)mod 2; if (j1=256) then i1:=i1+1;j1:=1; else j1:=j1+1; end if; IN_data(i2-1,j2-1)

10、=IN_data(i2-1,j2-1)+(IN_data(i2-1,j2-1)mod 2)+1)mod 2; if (j2=256) then i2:=i2+1;j2:=1; else j2:=j2+1; end if; IN_data(i2-1,j2-1)=IN_data(i2-1,j2-1)-(IN_data(i2-1,j2-1)mod 2)+0)mod 2; if (j2=256) then i2:=i2+1;j2:=1; else j2:=j2+1; end if; IN_data(i2-1,j2-1)=IN_data(i2-1,j2-1)+(IN_data(i2-1,j2-1)mod

11、 2)+1)mod 2; if (j2=256) then i2:=i2+1;j2:=1; else j2:=j2+1; end if; IN_data(i2-1,j2-1)=IN_data(i2-1,j2-1)-(IN_data(i2-1,j2-1)mod 2)+0)mod 2; if (j2=256) then i2:=i2+1;j2:=1; else j2:=j2+1; end if; IN_data(i2-1,j2-1)=IN_data(i2-1,j2-1)+(IN_data(i2-1,j2-1)mod 2)+1)mod 2; if (j2=256) then i2:=i2+1;j2:

12、=1; else j2:=j2+1; end if; IN_data(i3-1,j3-1)=IN_data(i3-1,j3-1)+(IN_data(i3-1,j3-1)mod 2)+1)mod 2; if (j3=256) then i3:=i3+1;j3:=1; else j3:=j3+1; end if; IN_data(i3-1,j3-1)=IN_data(i3-1,j3-1)+(IN_data(i3-1,j3-1)mod 2)+1)mod 2; if (j3=256) then i3:=i3+1;j3:=1; else j3:=j3+1; end if; IN_data(i3-1,j3

13、-1)=IN_data(i3-1,j3-1)-(IN_data(i3-1,j3-1)mod 2)+0)mod 2; if (j3=256) then i3:=i3+1;j3:=1; else j3:=j3+1; end if; IN_data(i3-1,j3-1)=IN_data(i3-1,j3-1)-(IN_data(i3-1,j3-1)mod 2)+0)mod 2; if (j3=256) then i3:=i3+1;j3:=1; else j3:=j3+1; end if; IN_data(i3-1,j3-1)=IN_data(i3-1,j3-1)+(IN_data(i3-1,j3-1)mod 2)+1)mod 2; if (j3=256) then i3:=i3+1;j3:=1;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号