APPENDIX-I
Synchronous communication creation
module rom8*8(y,in); output [7:0] y; input [2:0] in;
reg [2:0] ROM [7:0]; assign y=ROM[in];
initial $readme mb(“rom_data.txt”,ROM,0,7); end module module fs32_test(); reg [2:0] testvectors[8:0]; reg clk; reg [10:0]N,err; reg a,b,c; fs d_t,e_t; fs32 DUT(a,b,c,d_t,e_t); initial begin $readmemb(“testvectors_fs32.txt”,testvectors); N=0;err=0; end always begin clk=0; #50; clk=1; #50; end
always @(posedge clk)begin a=testvectors[N][0];
b=testvectors[N][1]; c=testvectors[N][2]; end
always @(nedge clk)begin N=N+1;
$display(“inputs %b%b%b-Output %b%b”,a,b,c,d_t,e_t); end
always @(N)begin
if(N==100||testvectors[N}===3’bx)begin
$display(“Completed %d tests with %d errors”,N,err); $finish; end end end module module fs32(x,y,bin,diff,bout); input x; input y; input bin; output diff; output bout; assign diff=x^y^bin;
assign bout=(y&bin)|((y|bin)&(~x)); end module
2. RA One’s and Two’s complement module
module complement’s (d, clk, q); input d; input clk; output q; flip [N-1:0] q1; dff dff1(d,clk,q1[0]); dff dff1(q1[0],clk,q1[1]); dff dff1(q1[1],clk,q1[2]); dff dff1(q1[N-1],clk,q); dff dff1(q1[N],clk q) end module module dff(d,clk,q); input d; input clk; output q; reg q; always @(posedge clk) q=d; end module (i) Adder and subtractor
module fa(a,b,cin,sum,cout); input [N:0]a; input [N:0]b; input cin; output [N:0] sum; output cout; fa[N-1:0] c1; fa fa1(a[0],b[0],cin, sum[0],c1[0]); fa fa2(a[1],b[1],c1[0], sum[1],c1[1]); fa fa(a[N-1],b[N-1],c1[1], sum[N-1],c1[N-1]); fa fa4(a[N],b[N],c1[N-1], sum[N],cout); end module module fa (a,b,cin,sum,cout); input a; input b; input cin; output sum; output cout; fa s1,c1,c2; xor xor1(s1,a,b); xor xor2(sum,s1,cin); and and1(c1,a,b); and and2(c2,s1,cin); or or1(cout,c1,c2); end module
APPENDIX-II
Resolving host in self-healing hardware
namespace NetPinger {
public partial class IPScanForm : Form {
private IPScanner _scanner;
private class HostSorterByIP : IComparer {
public int Compare(object x, object y) {
byte[ ] bytes1 =(IPScanHostState)((ListViewItem)x).Tag).Address.GetAddressBytes(); byte[ ] bytes2 = ((IPScanHostState)((ListViewItem)y).Tag).Address.GetAddressBytes(); int i = bytes1.Length - 1;
for (; i > 0 && bytes1[i] == bytes2[i]; i--); return bytes1[i] - bytes2[i];
}}
public IPScanForm() {
InitializeComponent();
_scanner = new IPScanner((int)_spnConcurrentPings.Value, (int)_spnPingsPerScan.Value, _cbContinuousScan.Checked,
(int)_spnTimeout.Value, (int)_spnTTL.Value, _cbDontFragment.Checked, (int)_spnBufferSize.Value); _scanner.OnAliveHostFound += new IPScanner.AliveHostFoundDelegate(_scanner_OnAliveHostFound); _scanner.OnStartScan += new IPScanner.ScanStateChangeDelegate(_scanner_OnStartScan);
_scanner.OnStopScan += new IPScanner.ScanStateChangeDelegate(_scanner_OnStopScan); _scanner.OnRestartScan += new IPScanner.ScanStateChangeDelegate(_scanner_OnRestartScan); _scanner.OnScanProgressUpdate += new
IPScanner.ScanProgressUpdateDelegate(_scanner_OnScanProgressUpdate); _lvAliveHosts.ListViewItemSorter = new HostSorterByIP(); _cmbRangeType.SelectedIndex = 0;
}
private void _scanner_OnAliveHostFound(IPScanner scanner, IPScanHostState host) {
if (InvokeRequired) {
BeginInvoke(new IPScanner.AliveHostFoundDelegate(_scanner_OnAliveHostFound), scanner, host); return;
}
ListViewItem item = new ListViewItem(); item.Tag = host; item.BackColor = Color.GreenYellow; item.SubItems.Add(host.Address.ToString()); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); _lvAliveHosts.Items.Add(item); _lvAliveHosts.Sort();
host.OnHostNameAvailable += new IPScanHostState.HostNameAvailableDelegate(host_OnHostNameAvailable); host.OnStateChange += new IPScanHostState.StateChangeDelegate(host_OnStateChange);
if (!host.IsTesting()) {
item.ImageIndex = (int)host.QualityCategory;
item.SubItems[2].Text = host.AvgResponseTime.ToString("F02") + " ms";
item.SubItems[3].Text = ((float)(host.LossCount) / host.PingsCount).ToString("P"); item.SubItems[4].Text = host.HostName;
}
2. Power analysis of self-healing hardware with IP Scanner
#region IPScanRange
Public class IPScanRange {
#region Start
Private IPAddress_start;
Public IPAddress Start {get {return_start;}}
public IPScanner(int concurrentPings, int pingsPerScan, bool continuousScan);
public IPScanner(int concurrentPings, int pingsPerScan, bool continuousScan, int timeout); public IPScanner(int concurrentPings, int pingsPerScan, bool continuousScan, int timeout, int ttl, bool dontFragment, int pingBufferSize);
IPScanRange(IPAddress start, IPAddress end); IPScanRange(IPAddress start, int subnet);
Appendix-III
Data synchronizing function of master module
Double_5 Send
function y = fcn() %#eml y = zeros(1,5); y(1) = 112; y(2) = 111.9991999; y(3) = 154524; y(4) = 11147.9991999; y(5) = 11241521.123455789;uint16 Send
function y = fcn() %#eml y=uint16(1120);uint8_2 Send
function y = fcn() %#eml y = uint8(zeros(1,2));y(1) = uint8(hex2dec('aa')); y(2) = uint8(hex2dec('ff'));
uint16_9 send
function y = fcn()
%#eml
y = uint16(zeros(1,9));
y(1) = uint16(hex2dec('aaff')); y(2) = uint16(hex2dec('ff00')); y(3) = uint16(hex2dec('55f0')); y(4) = uint16(hex2dec('aaaa')); y(5) = uint16(hex2dec('ffff')); y(6) = uint16(hex2dec('f520')); y(7) = uint16(hex2dec('aabc')); y(8) = uint16(hex2dec('ffed')); y(9) = uint16(hex2dec('f052'));
uint32_10 Send
function y = fcn()
%#eml
y = uint32(zeros(1,10));
y(1) = uint32(hex2dec('ee33aaff')); y(2) = uint32(hex2dec('ff001423')); y(3) = uint32(hex2dec('f0d5a400')); y(4) = uint32(hex2dec('aaaa1111')); y(5) = uint32(hex2dec('ffffbbbb'));
y(6) = uint32(hex2dec('f520aaaa')); y(7) = uint32(hex2dec('aabe4a6c')); y(8) = uint32(hex2dec('ffed2563')); y(9) = uint32(hex2dec('f052aaaa')); y(10) = uint32(1234567890);
double_2 Send
function y = fcn() %#eml y=zeros(1,2); y(1)=1; y(2)=1;double_2 Receive
function [x, y] = fcn(u) %#eml x = u(2); y = u(1);double_5 Receive
function y = fcn(u) %#emly = uint8(abs(u(1) - 112) < 1e-6 && abs(u(2) - 111.9991999) < 1e-6 && ...
abs(u(3) - 154524) < 1e-6 && abs(u(4) - 11147.9991999) < 1e-6 && ... abs(u(5) - 11241521.123455789) < 1e-6); u(1) = 0; u(2) = 0; u(3) = 0; u(4) = 0; u(5) = 0;
unit16 Receive
function y = fcn(u) %#eml y = uint8(uint16(1120)== u); u = uint16(0);Uint8_2 Receive
function y = fcn(u) %#emly = uint8(uint8(hex2dec('aa')) == u(1) && uint8(hex2dec('ff')) == u(2)); u(1)=0; u(2)=0;
Uint16_9 Receive
function y = fcn(u) %#emly = uint8(u(1) == uint16(hex2dec('aaff')) && u(2) == uint16(hex2dec('ff00')) && ...
u(3) == uint16(hex2dec('55f0')) && u(4) == uint16(hex2dec('aaaa')) && ...
u(5) == uint16(hex2dec('ffff')) && u(6) == uint16(hex2dec('f520')) && ...
u(7) == uint16(hex2dec('aabc')) && u(8) == uint16(hex2dec('ffed')) && ...
u(9) == uint16(hex2dec('f052'))); u(1)=0; u(2)=0; u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0;
uint32_10 Receive
function y = fcn(u) %#emly = uint8(u(1) == uint32(hex2dec('ee33aaff')) && u(2) == uint32(hex2dec('ff001423')) && ...
u(3) == uint32(hex2dec('f0d5a400')) && u(4) == uint32(hex2dec('aaaa1111')) && ...
u(5) == uint32(hex2dec('ffffbbbb')) && u(6) == uint32(hex2dec('f520aaaa')) && ...
u(7) == uint32(hex2dec('aabe4a6c')) && u(8) == uint32(hex2dec('ffed2563')) && ...
u(9) == uint32(hex2dec('f052aaaa')) && u(10) == uint32(1234567890)); u(1)=0; u(2)=0; u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; u(10)=0;
AND
function y = fcn(t,u,v,w,z) %#emlif(uint8(t) && uint8(z) && uint8(u) && uint8(v) && uint8(w)) y=uint8(1);
else
y=uint8(0); end
Appendix-IV
Data synchronizing function of slave module
Double_5 Send
function y = fcn() %#eml y = double(zeros(1,5)); y(1) = double(112); y(2)= double(111.9991999); y(3) = double(154524); y(4)= double(11147.9991999); y(5) = double(11241521.123455789); uint16 Send function y = fcn() %#eml y=uint16(1120); uint8_2 Send function y = fcn() %#eml y = uint8(zeros(1,2));y(1) = uint8(hex2dec('aa')); y(2) = uint8(hex2dec('ff'));
uint16_9 Send function y = fcn()
%#eml
y = uint16(zeros(1,9));
y(1) = uint16(hex2dec('aaff')); y(2) = uint16(hex2dec('ff00')); y(3) = uint16(hex2dec('55f0')); y(4) = uint16(hex2dec('aaaa')); y(5) = uint16(hex2dec('ffff')); y(6) = uint16(hex2dec('f520')); y(7) = uint16(hex2dec('aabc')); y(8) = uint16(hex2dec('ffed')); y(9) = uint16(hex2dec('f052'));
uint32_10
function y = fcn()
%#eml
y = uint32(zeros(1,10));
y(1) = uint32(hex2dec('ee33aaff')); y(2) = uint32(hex2dec('ff001423')); y(3) = uint32(hex2dec('f0d5a400')); y(4) = uint32(hex2dec('aaaa1111')); y(5) = uint32(hex2dec('ffffbbbb')); y(6) = uint32(hex2dec('f520aaaa')); y(7) = uint32(hex2dec('aabe4a6c'));
y(8) = uint32(hex2dec('ffed2563')); y(9) = uint32(hex2dec('f052aaaa')); y(10) = uint32(1234567890); double_2 Send function y = fcn(u,v ) %#eml y = zeros(1,2); y(1) = u; y(2) = v; double_5 Receive function y = fcn(u) %#eml
y = uint8(abs(u(1) - double(112)) < 1e-6 && abs(u(2) - double(111.9991999)) < 1e-6 && ...
abs(u(3) - double(154524)) < 1e-6 && abs(u(4) - double(11147.9991999)) < 1e-6 && ...
abs(u(5) - double(11241521.123455789)) < 1e-6); u(1)=0; u(2)=0; u(3)=0; u(4)=0; u(5)=0; uint16 Receive function y = fcn(u) %#eml y = uint8(uint16(1120)== u); u = uint16(0); uint8_3 Receive function y = fcn(u) %#eml
y = uint8(uint8(hex2dec('aa')) == u(1) && uint8(hex2dec('ff')) == u(2)); u(1)=0; u(2)=0; unit16_9 Receive function y = fcn(u) %#eml
y = uint8(u(1) == uint16(hex2dec('aaff')) && u(2) == uint16(hex2dec('ff00')) && ...
u(3) == uint16(hex2dec('55f0')) && u(4) == uint16(hex2dec('aaaa')) && ...
u(5) == uint16(hex2dec('ffff')) && u(6) == uint16(hex2dec('f520')) && ...
u(7) == uint16(hex2dec('aabc')) && u(8) == uint16(hex2dec('ffed')) && ...
u(1)=0; u(2)=0; u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; uint32_10 Receive function y = fcn(u) %#eml
y = uint8(u(1) == uint32(hex2dec('ee33aaff')) && u(2) == uint32(hex2dec('ff001423')) && ...
u(3) == uint32(hex2dec('f0d5a400')) && u(4) == uint32(hex2dec('aaaa1111')) && ...
u(5) == uint32(hex2dec('ffffbbbb')) && u(6) == uint32(hex2dec('f520aaaa')) && ...
u(7) == uint32(hex2dec('aabe4a6c')) && u(8) == uint32(hex2dec('ffed2563')) && ...
u(9) == uint32(hex2dec('f052aaaa')) && u(10) == uint32(1234567890)); u(1)=0; u(2)=0; u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; u(10)=0; double_2 Receive function [x, y] = fcn(u) %#eml x = uint8(u(1)); y = uint8(u(2)); AND function y = fcn(t,u,v,w,z) %#eml
if(uint8(t) && uint8(z) && uint8(u) && uint8(v) && uint8(w))
y=uint8(1); else
y=uint8(0); end